Answered File DLL Creation

  • Tuesday, March 27, 2012 3:56 PM
     
      Has Code

    Hello,

    how can Icreate a DLL file from an WPF application
    to use as a reference for example:

    namespace GestionDeProcessus
    {
    	using System;
    	using System.Threading;
    
    
    	class NombrePremier
    	{
    		[STAThread]
    		static void Main(string[] args)
    		{
    			// L'instence de ThreadStart demande un delegate en paramètre ce qui est plus
    			// ou moins (mais pas vraiment) l'équivalent d'un pointeur de fonction
    			
    			Thread t = new Thread(new ThreadStart(ThreadFunction));
    			
    			t.Start();
    		}
    
    		private static void ThreadFunction()
    		{
    			for(int p=1;p<1000000; p++)
    			{
    				int i=2;
    				while((p%i)!=0 && i<p)
    				{
    					i++;
    				}
    				if(i==p)
    					Console.WriteLine(p.ToString());
    					Thread.Sleep(50);
    				
    			}
    		}
    	}
    }
    
    
    Thank's



    Rayo_Muchacho

All Replies

  • Tuesday, March 27, 2012 4:08 PM
     
     
    A DLL doesn't have the same entry point as a WPF application, meaning that Main() doesn't map to a class library.  What are you trying to accomplish?

    Jose R. MCP

  • Tuesday, March 27, 2012 5:06 PM
     
     Answered
    If you're trying to have ThreadFunction be a method that you want loaded into different applications, you can create a new class library project, write the ThreadFunction there, and then have this executable (and any other project) reference that dll.
  • Tuesday, March 27, 2012 5:23 PM
     
     

    You will need to use reflection.  See this series in the MSDN library: http://msdn.microsoft.com/en-us/library/f7ykdhsy.aspx.

    C# is fully object oriented.  Unlike C, where you can have just a method in a DLL, you need to stick the function in a class in an assembly.

  • Thursday, March 29, 2012 8:25 AM
     
     
    Thank's for your responses

    Rayo_Muchacho

  • Thursday, March 29, 2012 1:24 PM
     
     
    If any of these helped or answered your question, remember to mark them as helpful or as the answers.