A
A
AbnormalUnit2012-03-19 17:52:45
.NET
AbnormalUnit, 2012-03-19 17:52:45

COM object from c#. Accessing a property?

Hello, now I will try to lay out the essence of the problem:
A number of com-libraries are registered and connected to the project.
I get the value like this:

ComObject1 com = new ComObject1();<br/>
string name = com.get_Property(&quot;name&quot;) as string;

I set the value like this:
((dynamic)com).name = &quot;Vasiliy&quot;;
The work is being done not with one object, but with several.
So:
1. Sometimes, in the property setter of the class that includes this com object, when I set a value for the name property of the com object, an exception falls out:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt

2.Okay, I set the same property only in the constructor of this class, so everything goes with a bang. Well, with a bang, and God be with him. But no, after that, work on a collection of some other com-objects is called from the constructor, which also contain the Name field. So, after setting the first one, the name does not allow you to set the name fields for objects in the collection. Writes that it cannot invoke Name.
These objects are not related in any way. If I do not set the name before working with the collection, then I will normally set these properties in the objects inside the collection.
In short, some such nonsense is happening.
Nobody faced this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xaizek, 2012-03-19
@xaizek

I occasionally see this kind of "nonsense" when working with COM, and it's always caused by errors in memory handling in the COM library (for example, premature destruction of an object due to errors in reference counting). I can’t say for sure that this is your case, but it looks very similar.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question