Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all
i wanted to register dll from code..
so form the given link i copied the code and tried it

http://www.zorched.net/2009/01/01/register-and-unregister-com-dll-from-net-code/[^]

but it is giving error as
The specified procedure could not be found


at this line

C#
IntPtr dllEntryPoint = GetProcAddress(hLib, methodName);
            if (IntPtr.Zero == dllEntryPoint)
            {
               error=> throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            PointerToMethodInvoker drs =
                   (PointerToMethodInvoker) Marshal.GetDelegateForFunctionPointer(dllEntryPoint,
                               typeof(PointerToMethodInvoker));
            drs();


any Help??
thank you

god bless u all
Posted
Updated 20-Jul-12 2:49am
v2
Comments
Richard MacCutchan 20-Jul-12 9:06am    
Does the string content in methodName actually match the name of a procedure in the library you have loaded?
MAU787 21-Jul-12 0:54am    
yes i have same method name in my class library
Richard MacCutchan 21-Jul-12 4:25am    
In that case it cannot be an exported procedure as the error message is quite clear.
BobJanova 20-Jul-12 12:22pm    
Check the calling convention of the DLL: is it compatible with LoadLibrary? Do you need to specify parameter-type suffices to the name?
MAU787 21-Jul-12 1:00am    
how to do it??

1 solution

To register a COM dll, you call regsvr32. There's no complex code or library required. ShellExecute is all you need.
 
Share this answer
 
Comments
MAU787 21-Jul-12 0:17am    
hi..thanx for reply
do you have any example code for it??
Christian Graus 21-Jul-12 1:50am    
Ooops - Process.Start is actually what you need. The rest is self documenting.
MAU787 21-Jul-12 2:09am    
i tried this code

Process ps;
ps = new Process();
String p= ps.StartInfo.FileName ="C:\\WINDOWS\\system32\\regsvr32.exe";
Console.WriteLine(p);
ps.StartInfo.Arguments = "C:\\AxComp.dll";
ps.StartInfo.UseShellExecute = false ;
ps.StartInfo.RedirectStandardOutput = true ;
ps.StartInfo.CreateNoWindow = true ;
ps.Start();

got error:
The module "C:\AxComp.dll" was loaded but the entry-point DllRegisterServer was not found.

Make sure that "C:\AxComp.dll" is a valid DLL or OCX file and then try again.
Christian Graus 21-Jul-12 2:14am    
Just make the filename regsvr32.exe, the system will find where it is. This looks like it worked just fine, now your problem is that your dll is not a valid COM dll.
MAU787 21-Jul-12 2:27am    
okk...thank you..:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900