Click here to Skip to main content
15,920,687 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello - I give up!

I would like to use a reg free COM component in my App. I looked for a sample program and found GitHub - AaronRobinsonMSFT/COMInterop: Example on how to consume a COM server from a .NET client and a .NET server from a COM client. Examples are for both using the Registry and for RegFree.[^] [^]

The sample contains a C++ COM server, as well a C# COM server. The C++ version works perfectly, but the C# version throws an exception System.InvalidCastException at instantiation
C#
var server = new Server()
.

I provide 2 ready-to-run projects at Dropbox - COMRegFree Sample.zip[^] . Just press F5 in visual studio. Can anybody tell me what is wrong or missing??

Thanks

What I have tried:

Downloaded the sample and tryed to get run.
Posted
Updated 26-May-24 21:43pm
v3
Comments
0x01AA 24-May-24 10:03am    
In other words: You can't start a regfree c# com server from a c# application?
Richard MacCutchan 25-May-24 4:54am    
You should ask the person who wrote the code.

1 solution

You don't provide much information other than a link to a github repo and a random Dropbox link that people are unlikely to follow.

An invalid cast happens when you attempt to cast a type to another, unsupported type. Presumably, somewhere in the Server construction call, you have a type that is being cast. You will need to set breakpoints to find the code that is the culprit.
 
Share this answer
 
Comments
Michael Sabo 27-May-24 3:40am    
That's right. I intentionally kept the description short and sweet. A long story tires the reader. I would like to have the attachment attached to the ticket. Unfortunately, this is probably not possible here.
Dave Kreskowiak 27-May-24 10:53am    
The quality of the answers you get is directly dictated by the quality of the questions you ask.

And no, you cannot attach files here, for good reason. You can, however, paste in the relevant code.
Michael Sabo 27-May-24 11:00am    
Do you have already analysed the code?
Dave Kreskowiak 27-May-24 11:35am    
I'm not downloading code from an untrusted site/user. I don't have virus problems on my machines and prefer to keep it that way.
Michael Sabo 28-May-24 3:07am    
Exactly! These are the bad creatures that are just waiting in text files for to destroy the computer. *lol*

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