Click here to Skip to main content
15,509,454 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
He guys

I’m banging my head over this the entire day and so far no joy. The facts:
I have a rather big COM object (> 1M LOC) which fails to unregister and is living a huge fingerprint in the registry. In the beginning there was no DllUnregisterServer entry point so I added it, but for some reason regsvr32 still giving an error that “The object is loaded but the DllUnregisterServer is not found”. I also put an assertion in the function body and I’m sure the function is never called.

This is the code:
STDAPI DllUnregisterServer(void)
{
	ASSERT(FALSE);
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	COleObjectFactory::UpdateRegistryAll(FALSE);
	return S_OK;
}


But the code in the function body doesn’t matter since the regsvr32 won’t call the function at all. Oh, and there is no problems with registering the object, only the /u option fails.

Any ideas will be appreciated, thanks!
Posted
Updated 25-Mar-11 10:03am
v2
Comments
Wendelius 25-Mar-11 15:04pm    
Pre tags added

Probably this is because you did not indicate this entry point should be exported from the DLL.

Consider
__declspec(dllexport) STDAPI DllUnregisterServer(void) { /*...*/ }


I suggest you check up what's exported using some binary dump utility such as dumpbin.exe, http://msdn.microsoft.com/en-us/library/c1h23y6c(v=vs.71).aspx[^] (to use this utility, it's best to start from "Visual Studio Command Prompt").

—SA
 
Share this answer
 
v4
Comments
Wendelius 25-Mar-11 15:16pm    
Seems like a good answer :) My 5.
Single Step Debugger 25-Mar-11 15:35pm    
Thank you for the straw, but the function is already declared in OleCtl.h in the SDK and I was assuming that I only need to implement it? At least this approach works for the other COM objects I used to deal with.
Sergey Alexandrovich Kryukov 25-Mar-11 15:48pm    
No, you always need to export the entry point. It can be *declared*, but also needs to be *defined* in the module you're supplying; do you see the difference? I don't know your other cases, but you can check up what's really exported using the same very dump utility.

So, will you formally accept my Answer?
Thank you,
--SA
Single Step Debugger 25-Mar-11 15:56pm    
Yes I will mark it as answer, thank you and I also five voted your answer. And I have explicit export for this function in the definition file but it still doesn’t work. I start thinking that something breaks the DLL initialization and the error message is just a side effect. Thank you anyway.
Single Step Debugger 25-Mar-11 16:06pm    
Yes you were perfectly right DUMPBIN tells me that the function is not exported. All other functions in the definition file are exported but not this one…weird.
Are you missing the entry point in order to export the function?

Additional info about the messages: http://support.microsoft.com/kb/249873[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 25-Mar-11 15:15pm    
I think I answered this way before.
--SA
Wendelius 25-Mar-11 15:20pm    
Yes, I noticed after submitting. Based on the code excerpt seems to be the obvious reason...
Sergey Alexandrovich Kryukov 25-Mar-11 15:23pm    
A 5 than... :-)
--SA
Albert Holguin 25-Mar-11 19:32pm    
They're WAY too fast with their Q&A answering! lol...
Single Step Debugger 25-Mar-11 16:22pm    
Yes I found this article earlier today but it’s not very helpful, it’s more like a reference. Thanks and have a five from me.

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