471,319 Members | 1,430 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Reference COM component fails in Visual Studio (ResolveComReference exception)

Hi,

I am trying to reference a COM component (.dll) from Visual Studio 2005
in my windows application in C# by adding a reference to a third
party.dll file (tried .type library also), and i get this error from
the compiler when trying to compile the solution.

Does anyone know why this occurs, and how it can be resloved, i would
be very grateful indeed.

Here comes the exception thrown:
------------------------------------------
Error 2 The "ResolveComReference" task failed unexpectedly.
System.SystemException: The type library importer encountered an error
during type verification. Try importing without class members. --->
System.TypeLoadException: Method 'IXorDiscountMatrix_GetName' on type
'XOR5.CXorDiscountMatrixClass' from assembly 'Interop.XOR5,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is overriding a
method that has been overridden.
at System.Reflection.Module.InternalLoadInMemoryTypeB yName(String
className)
at
System.Runtime.InteropServices.TypeLibConverter.Ty peResolveHandler.ResolveEvent(Object
sender, ResolveEventArgs args)
at System.AppDomain.OnTypeResolveEvent(String typeName)
--- End of inner exception stack trace ---

Server stack trace:
at
System.Runtime.InteropServices.TypeLibConverter.nC onvertTypeLibToMetadata(Object
typeLib, AssemblyBuilder asmBldr, ModuleBuilder modBldr, String
nameSpace, TypeLibImporterFlags flags, ITypeLibImporterNotifySink
notifySink, ArrayList& eventItfInfoList)
at
System.Runtime.InteropServices.TypeLibConverter.Co nvertTypeLibToAssembly(Object
typeLib, String asmFileName, TypeLibImporterFlags flags,
ITypeLibImporterNotifySink notifySink, Byte[] publicKey,
StrongNameKeyPair keyPair, String asmNamespace, Version asmVersion)
at
Microsoft.Build.Tasks.TlbReference.GenerateWrapper (ComReferenceWrapperInfo&
wrapperInfo)
at
Microsoft.Build.Tasks.ResolveComReference.ResolveC omReferenceTlb(ComReferenceInfo
referenceInfo, String outputDirectory, String refName, Boolean
topLevelRef, ComReferenceWrapperInfo& wrapperInfo)
at
Microsoft.Build.Tasks.ResolveComReference.ResolveC omClassicReference(ComReferenceInfo
referenceInfo, String outputDirectory, String wrapperType, String
refName, Boolean topLevelRef, ComReferenceWrapperInfo& wrapperInfo)
at
Microsoft.Build.Tasks.ResolveComReference.ResolveR eference(ComReferenceInfo
referenceInfo, String outputDirectory, ITaskItem& referencePathItem)
at
Microsoft.Build.Tasks.ResolveComReference.ResolveR eferenceAndAddToList(ComReferenceInfo
projectRefInfo, ArrayList resolvedReferenceList, ArrayList moduleList)
at Microsoft.Build.Tasks.ResolveComReference.Execute( )
at
System.Runtime.Remoting.Messaging.StackBuilderSink ._PrivateProcessMessage(IntPtr
md, Object[] args, Object server, Int32 methodPtr, Boolean
fExecuteInContext, Object[]& outArgs)
at
System.Runtime.Remoting.Messaging.StackBuilderSink .PrivateProcessMessage(RuntimeMethodHandle
md, Object[] args, Object server, Int32 methodPtr, Boolean
fExecuteInContext, Object[]& outArgs)
at
System.Runtime.Remoting.Messaging.StackBuilderSink .SyncProcessMessage(IMessage
msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:
at
System.Runtime.Remoting.Proxies.RealProxy.HandleRe turnMessage(IMessage
reqMsg, IMessage retMsg)
at
System.Runtime.Remoting.Proxies.RealProxy.PrivateI nvoke(MessageData&
msgData, Int32 type)
at Microsoft.Build.Framework.ITask.Execute()
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask (ExecutionMode
howToExecuteTask, Hashtable projectItemsAvailableToTask,
BuildPropertyGroup projectPropertiesAvailableToTask, Boolean&
taskClassWasFound) Control.Import.Filter
Sincerely
/Hans Sixhöj
Software Developer

Feb 3 '06 #1
4 10063
Run tlbimp.exe on the DLL/TLB. When you do, use the /noclassmembers
option, so that class members are not created from the implemented
interfaces. It looks like there are two interfaces with similar method
signatures which are giving you problems.

This will remove the members from the class (so all you do is use it to
create the object). It will require you to cast to the appropriate
interface to access the methods exposed by the object.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ff******@hotmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Hi,

I am trying to reference a COM component (.dll) from Visual Studio 2005
in my windows application in C# by adding a reference to a third
party.dll file (tried .type library also), and i get this error from
the compiler when trying to compile the solution.

Does anyone know why this occurs, and how it can be resloved, i would
be very grateful indeed.

Here comes the exception thrown:
------------------------------------------
Error 2 The "ResolveComReference" task failed unexpectedly.
System.SystemException: The type library importer encountered an error
during type verification. Try importing without class members. --->
System.TypeLoadException: Method 'IXorDiscountMatrix_GetName' on type
'XOR5.CXorDiscountMatrixClass' from assembly 'Interop.XOR5,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is overriding a
method that has been overridden.
at System.Reflection.Module.InternalLoadInMemoryTypeB yName(String
className)
at
System.Runtime.InteropServices.TypeLibConverter.Ty peResolveHandler.ResolveEvent(Object
sender, ResolveEventArgs args)
at System.AppDomain.OnTypeResolveEvent(String typeName)
--- End of inner exception stack trace ---

Server stack trace:
at
System.Runtime.InteropServices.TypeLibConverter.nC onvertTypeLibToMetadata(Object
typeLib, AssemblyBuilder asmBldr, ModuleBuilder modBldr, String
nameSpace, TypeLibImporterFlags flags, ITypeLibImporterNotifySink
notifySink, ArrayList& eventItfInfoList)
at
System.Runtime.InteropServices.TypeLibConverter.Co nvertTypeLibToAssembly(Object
typeLib, String asmFileName, TypeLibImporterFlags flags,
ITypeLibImporterNotifySink notifySink, Byte[] publicKey,
StrongNameKeyPair keyPair, String asmNamespace, Version asmVersion)
at
Microsoft.Build.Tasks.TlbReference.GenerateWrapper (ComReferenceWrapperInfo&
wrapperInfo)
at
Microsoft.Build.Tasks.ResolveComReference.ResolveC omReferenceTlb(ComReferenceInfo
referenceInfo, String outputDirectory, String refName, Boolean
topLevelRef, ComReferenceWrapperInfo& wrapperInfo)
at
Microsoft.Build.Tasks.ResolveComReference.ResolveC omClassicReference(ComReferenceInfo
referenceInfo, String outputDirectory, String wrapperType, String
refName, Boolean topLevelRef, ComReferenceWrapperInfo& wrapperInfo)
at
Microsoft.Build.Tasks.ResolveComReference.ResolveR eference(ComReferenceInfo
referenceInfo, String outputDirectory, ITaskItem& referencePathItem)
at
Microsoft.Build.Tasks.ResolveComReference.ResolveR eferenceAndAddToList(ComReferenceInfo
projectRefInfo, ArrayList resolvedReferenceList, ArrayList moduleList)
at Microsoft.Build.Tasks.ResolveComReference.Execute( )
at
System.Runtime.Remoting.Messaging.StackBuilderSink ._PrivateProcessMessage(IntPtr
md, Object[] args, Object server, Int32 methodPtr, Boolean
fExecuteInContext, Object[]& outArgs)
at
System.Runtime.Remoting.Messaging.StackBuilderSink .PrivateProcessMessage(RuntimeMethodHandle
md, Object[] args, Object server, Int32 methodPtr, Boolean
fExecuteInContext, Object[]& outArgs)
at
System.Runtime.Remoting.Messaging.StackBuilderSink .SyncProcessMessage(IMessage
msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:
at
System.Runtime.Remoting.Proxies.RealProxy.HandleRe turnMessage(IMessage
reqMsg, IMessage retMsg)
at
System.Runtime.Remoting.Proxies.RealProxy.PrivateI nvoke(MessageData&
msgData, Int32 type)
at Microsoft.Build.Framework.ITask.Execute()
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask (ExecutionMode
howToExecuteTask, Hashtable projectItemsAvailableToTask,
BuildPropertyGroup projectPropertiesAvailableToTask, Boolean&
taskClassWasFound) Control.Import.Filter
Sincerely
/Hans Sixhöj
Software Developer
Feb 3 '06 #2
Hi,

Thanks for your fast response, it worked to create a new .dll file.

The original .dll file (in COM) belongs to a program not built by me. I
need to respond to events triggered in this application when the user
performs different actions (worked in VB) (listen to events from an
interface). Will this be possible although i have created a new .dll
file?

If not, is there a way to achive this?

Sincerely
/Hans Sixhöj
Systems Developer

Feb 3 '06 #3
Hans,

Well, when you set a reference in Visual Studio .NET, you are still
creating your own interop DLL to use. What you are doing here is no
different, you just have more options available to you.

So yes, you should have access to all of the functionality exposed by
the object.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ff******@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi,

Thanks for your fast response, it worked to create a new .dll file.

The original .dll file (in COM) belongs to a program not built by me. I
need to respond to events triggered in this application when the user
performs different actions (worked in VB) (listen to events from an
interface). Will this be possible although i have created a new .dll
file?

If not, is there a way to achive this?

Sincerely
/Hans Sixhöj
Systems Developer
Feb 3 '06 #4
Thank you for your answers.

The issue has been resolved.

Thank you very much.

Sincerely,
/Hans Sixhöj
Software Developer

Feb 3 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Pkpatel | last post: by
6 posts views Thread by jemmaq99 | last post: by
6 posts views Thread by Ali-R | last post: by
4 posts views Thread by =?Utf-8?B?V2lsbWVyIEhlcm5hbmRleg==?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.