Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

while calling a C++ COM empty function,getting error "Attempted to read or write protected memory. This is often an indication that other memory is corrupt.""

Posted on 2013-06-19
6
Medium Priority
?
425 Views
Last Modified: 2013-06-23
Hello All

While calling a C++ COM empty function,getting error "Attempted to read or write protected memory. This is often an indication that other memory is corrupt.""

Please help.
0
Comment
Question by:BYTECHINDIA
  • 2
  • 2
  • 2
6 Comments
 
LVL 16

Assisted Solution

by:George Tokas
George Tokas earned 999 total points
ID: 39261254
Most likely the COM object is not created and you are calling a member function on a non-initialized component...
Try adding a breakpoint at the line raizing the exception and examine the components handler...
This message looks like from managed code so you will see a description "no valid...(something)" or something similar...

George Tokas.
0
 

Author Comment

by:BYTECHINDIA
ID: 39262037
Now when we have changed the location to other server and run the application in c# which is basically calling c++COM DLL empty function,getting error "Exception from HRESULT: 0xC0000005 ",no other detail is coming.I am not able to find out that whether this is from C# code or from c++ DLL.
0
 
LVL 16

Assisted Solution

by:George Tokas
George Tokas earned 999 total points
ID: 39262084
0xC0000005 is access violation code caused from what I described earlier but also an attempt to call a method on a released object...
Exception from HRESULT means that it is something like that:
HRESULT hr = NULL;
hr = functionfromdll();
functionfromdll() is calling a method or function on a NON existent component, it is not just an empty com function...
That means that the dll has to export a creation (new instance of the component) somehow...
In a very few words you are missing a function call needed to create and init the com object...

George Tokas.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Accepted Solution

by:
sarabande earned 501 total points
ID: 39262145
what do you mean by 'COM empty function'?

generally, the error you reported is when using a com pointer that is not valid, or that is not fully initialized, or that was no more valid because of an unsuccessful call before. normally you can avoid those errors by always verifying com objects before use.

Sara
0
 
LVL 35

Expert Comment

by:sarabande
ID: 39262265
access violation is pointer error. so it is more likely to happen in c++ dll.

can you run the program in debug mode from visual studio ide?

Sara
0
 

Author Closing Comment

by:BYTECHINDIA
ID: 39269648
Thanks to all..
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question