Click here to Skip to main content
15,893,381 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# FormatCurrency(VB) to ToString Pin
Pete O'Hanlon12-Nov-14 10:58
mvePete O'Hanlon12-Nov-14 10:58 
GeneralRe: C# FormatCurrency(VB) to ToString Pin
Dominic Burford13-Nov-14 4:25
professionalDominic Burford13-Nov-14 4:25 
GeneralRe: C# FormatCurrency(VB) to ToString Pin
Pete O'Hanlon13-Nov-14 4:49
mvePete O'Hanlon13-Nov-14 4:49 
GeneralRe: C# FormatCurrency(VB) to ToString Pin
Dominic Burford13-Nov-14 5:34
professionalDominic Burford13-Nov-14 5:34 
AnswerRe: C# FormatCurrency(VB) to ToString PinPopular
Dave Kreskowiak12-Nov-14 11:13
mveDave Kreskowiak12-Nov-14 11:13 
GeneralRe: C# FormatCurrency(VB) to ToString Pin
Bernhard Hiller12-Nov-14 21:15
Bernhard Hiller12-Nov-14 21:15 
AnswerRe: C# FormatCurrency(VB) to ToString Pin
Dominic Burford13-Nov-14 5:34
professionalDominic Burford13-Nov-14 5:34 
QuestionStrange thing with AsemblyResolve event Pin
Marcos Bischoff12-Nov-14 4:28
Marcos Bischoff12-Nov-14 4:28 
Hi there.
The .NET applications I provide for our test team are using the same set of assemblys. Depending on which test teams uses the app the corresponing assembly will be loaded at runtime.
Easy stuff. One must just handle the AppDomain.ResolveAssembly event properly and everything is fine. So when the app isn't able to resolve a type I simple check all loaded assemblys.

Doing that i came up with the idea, that if I cannot find a depended assembly it is properly because it is missing in the apps working directory. So I could copy it from our file server to the WD and simple load it.
With this mechanism I am able to roll out a new app simple by distributing the executable and on start the app will collect it's dependencies by itself.
Neat stuff. Worked fine for anything invovling WinddowsForms and WPF.

Now with console application the hole thing went kaputt.
Instead of any event being triggered the hole console application just crashed. NO UnhandledException even or any catch just a big kernel32 APPCRASH.
After a hole day of brainfuck, I found a solution but I don't get it.

Here is the thing:
Normally console applications aren't that big so the mayor coding stays in the main(string[] args) method.
Here is a constructed example:
C#
public static void Main(string [ ] args)
    {
      AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler ( ConsoleExceptionHandler.CurrentDomain_UnhandledExceptionConsole);
      AppDomain.CurrentDomain.AssemblyResolve += (AssemblyResolver.CurrentDomain_AssemblyResolve);

      Console.WriteLine ( typeof ( JobData ).ToString () );
      Console.WriteLine ( typeof ( TSExecTask ).ToString () );
      Console.WriteLine ( typeof ( ReportingTask).ToString () );
      Console.ReadLine ();
    }

which does not work. But if I move the three Console.WriteLine in a separate class (ConsoleCrap) it works.
C#
public static void Main(string [ ] args)
    {
      AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler ( ConsoleExceptionHandler.CurrentDomain_UnhandledExceptionConsole);
      AppDomain.CurrentDomain.AssemblyResolve += (AssemblyResolver.CurrentDomain_AssemblyResolve);

      System.Threading.Thread.Sleep ( 100 );
      new ConsoleCrap ().WriteSome ();
      Console.ReadLine ();
    }


I thought maybe, by postponing the point where the missing types are needed, the event has the nessesary time to collect the assemblys.
But the AsssemblyResolve event isn't asynchronous. So the actual execution flow is on hold while the type is not resolved.

On the other hand maybe the issue is, that by using the missing types directly the class containing the the static main() method cannot be laoded as it is missing the assembly before the AssemblyResolve event is registered.

So my question to all knowing more of coding then myself. (basically the rest of the universe)

Maybe someone si abel to givve ma some insight?
AnswerRe: Strange thing with AsemblyResolve event Pin
Eddy Vluggen12-Nov-14 8:05
professionalEddy Vluggen12-Nov-14 8:05 
AnswerRe: Strange thing with AsemblyResolve event Pin
Freak3013-Nov-14 1:11
Freak3013-Nov-14 1:11 
QuestionQuick Loading of WPF application Pin
teek1312-Nov-14 2:42
teek1312-Nov-14 2:42 
AnswerRe: Quick Loading of WPF application Pin
SledgeHammer0112-Nov-14 5:04
SledgeHammer0112-Nov-14 5:04 
GeneralRe: Quick Loading of WPF application Pin
teek1312-Nov-14 8:32
teek1312-Nov-14 8:32 
GeneralRe: Quick Loading of WPF application Pin
SledgeHammer0112-Nov-14 8:59
SledgeHammer0112-Nov-14 8:59 
GeneralRe: Quick Loading of WPF application Pin
Eddy Vluggen12-Nov-14 9:15
professionalEddy Vluggen12-Nov-14 9:15 
GeneralRe: Quick Loading of WPF application Pin
teek1312-Nov-14 19:04
teek1312-Nov-14 19:04 
GeneralRe: Quick Loading of WPF application Pin
SledgeHammer0112-Nov-14 19:21
SledgeHammer0112-Nov-14 19:21 
GeneralRe: Quick Loading of WPF application Pin
teek1313-Nov-14 0:11
teek1313-Nov-14 0:11 
GeneralRe: Quick Loading of WPF application Pin
SledgeHammer0113-Nov-14 6:55
SledgeHammer0113-Nov-14 6:55 
GeneralRe: Quick Loading of WPF application Pin
teek1313-Nov-14 7:22
teek1313-Nov-14 7:22 
GeneralRe: Quick Loading of WPF application Pin
SledgeHammer0113-Nov-14 9:12
SledgeHammer0113-Nov-14 9:12 
AnswerRe: Quick Loading of WPF application Pin
Eddy Vluggen12-Nov-14 8:04
professionalEddy Vluggen12-Nov-14 8:04 
GeneralRe: Quick Loading of WPF application Pin
teek1312-Nov-14 8:40
teek1312-Nov-14 8:40 
GeneralRe: Quick Loading of WPF application Pin
Eddy Vluggen12-Nov-14 9:14
professionalEddy Vluggen12-Nov-14 9:14 
AnswerRe: Quick Loading of WPF application Pin
Pete O'Hanlon12-Nov-14 9:43
mvePete O'Hanlon12-Nov-14 9:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.