Click here to Skip to main content

PaulowniaK asked:

Open original thread
I have a COM written in C++ accessed by .NET C# application.
 
The COM was originally written by someone else and has already been launched as a product many years ago.
 
Now, I've had to make alterations to it.
 
I added a few interfaces and this seems to work.
 
I then added a few methods to an interface that existed before I inherited this job. The C# application accessing it thinks that it is made to write into protected memory and fails at runtime.
 
The C# bit definitely knows that the new methods exist.
 
It's not some memory allocation problem within the COM as I've debugged from the COM side as well and it doesn't get as far as calling the COM methods.
 
Have I missed something?
 
// MyCOM.idl
[ 
 object, 
 uuid(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX),
 oleautomation,
 pointer_default(unique)
]
interface IMyInterface: IUnknown
{
	[helpstring("method Method1") HRESULT Method1();
	[helpstring("method MethodNewlyAdded") HRESULT MethodNewlyAdded();
}
 
[ 
 object, 
 uuid(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX),
 oleautomation,
 pointer_default(unique)
]
interface INewInterface: IUnknown
{
	[helpstring("method NewMethod") HRESULT NewMethod();
}
 
coclass MyCoClass
{
	interface IMyInterface;
	interface INewInterface;
}
 
// MyApp.cs
public void MyAppMethod()
{
	MyCOM.IMyInterface myCOM = new MyCOM.IMyInterface;
	myCOM.Method1(); // OK
	myCOM.MethodNewlyAdded(); // Unhandled memory exception!

 
	MyCOM.INewInterface myNewCOM = new MyCOM.INewInterface;
	myNewCOM.NewMethod(); // OK
}
Tags: C++, C#, COM

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100