Mathew1972

Hello,

Does anybody know why C# removes physical .EXE file from the DEBUG folder after you change the setting to create a .DLL from your application. How is it's mechanism

Is there any setting to set to keep the .EXE file as well.

Thanks,

Mathew



Re: Windows Forms Data Controls and Databinding C#: Windows Form Application (DLL)

Brendan Grant

Off hand I cannot say how this happens behind the scenes or how it could be prevented... but I still have to ask... why is it you want to keep an old build of your project around in such a form What is it you are trying to achieve Perhaps there is a better way.




Re: Windows Forms Data Controls and Databinding C#: Windows Form Application (DLL)

Mathew1972

Hello,

Thanks for your reply.

I have an application which I need to call it from my other applications. I want to have a dll of it, to be able to call it.

As you said, there might be a better way to do this. Please let me know what is the best way of doing this, and if there is any solution for my original question, I will be glad to know that.

Thanks again,

Mathew





Re: Windows Forms Data Controls and Databinding C#: Windows Form Application (DLL)

Brendan Grant

I know you want it to be a dll... but do remember that if it was an exe you can simply use Process.Start() to start the sub programs.

Does the calling program know about the sub programs ahead of time If so and the parent app references the sub app... you could manually call the appropriate startup method/object in the sub program just as you¡¯d access another referenced class.

If you do not have a reference to the sub apps at compile time, its a little more work to call over to it and create a new object or execute the entry point...

The problem with executing a standalone program inside of a dll is that there is no pre-defined entry point as there is in an exe... assuming one is defined and you¡¯ve referenced the assembly it is contained within... you can simply invoke the entry point:

Assembly a = Assembly.LoadFile(@"C:\SomeDir\SomeAssembly.exe");

a.EntryPoint.Invoke(null, null);

This assumes that there is nothing going on in the sub app that conflicts with the parent one (such as calls to Application.Run() and Application.SetCompatibleTextRenderingDefault() ).

If you were to use the above code against a dll, you¡¯d get a NullReferenceException as EntryPoint is null... instead you¡¯d need to know the method name you want to call, and in a default project named WindowsApplication1... the work to manually invoke the method previously known as the entry point would look something like this:

Assembly a = Assembly.LoadFile(@"C:\SomeDir\SomeAssembly.exe");

//Reference specific class

Type t = a.GetType("WindowsApplication1.Program");

//Locate specific method as part of class

MethodInfo mi = t.GetMethod("Main", BindingFlags.Static | BindingFlags.NonPublic);

mi.Invoke(null, null);