473,394 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Managed Code From Unmanaged Code Issues On Vista

We are having an issue with an application we are developing. We have a
Legacy COM DLL in C++ that we have converted to Visual Studio 2008. This COM
DLL has methods that are calling Managed C# assemblies as pass thru to
support legacy applications in an effort to move our code to the new Code
base. Our COM Object can be instantiated on Windows XP in any COM supported
environment using Visual C++, Visual Basic, ASP.NET or ASP and works without
any issues or throwing any exceptions. When we use the object on a Vista
Machine the method fails only when it is used in a Classic ASP page. We are
initializing the Managed code in the Unmanaged code using
gcroot<MYOBJ::FOOBAR^myObj; on the constructor, when we create an instance
of the object is when it seems to fail. We have attempted creating our
instance by using myObj = gcnew MYOBJ::FOOBAR(); in the constructor but this
caused the object to fail on CreateObject, this was moved into the calling
method. Now the object is created but now fails on the method call. We have
attempted to instanciate it using myOBJ = gcnew MYOBJ:FOOBAR(); and gcnew
MYOBJ::FOOBAR; both work in Windows XP but do not work on Vista. All
assemblies are in the same directory together and have permissions set to
access all the files.
Oct 15 '08 #1
4 2206
HI viperx1967,
We are having an issue with an application we are developing. We have
a Legacy COM DLL in C++ that we have converted to Visual Studio 2008.
This COM DLL has methods that are calling Managed C# assemblies as
pass thru to support legacy applications in an effort to move our
code to the new Code base. Our COM Object can be instantiated on
Windows XP in any COM supported environment using Visual C++, Visual
Basic, ASP.NET or ASP and works without any issues or throwing any
exceptions. When we use the object on a Vista Machine the method
fails only when it is used in a Classic ASP page. We are initializing
the Managed code in the Unmanaged code using gcroot<MYOBJ::FOOBAR^>
myObj; on the constructor, when we create an instance of the object
is when it seems to fail. We have attempted creating our instance by
using myObj = gcnew MYOBJ::FOOBAR(); in the constructor but this
caused the object to fail on CreateObject, this was moved into the
calling method. Now the object is created but now fails on the method
call. We have attempted to instanciate it using myOBJ = gcnew
MYOBJ:FOOBAR(); and gcnew MYOBJ::FOOBAR; both work in Windows XP but
do not work on Vista. All assemblies are in the same directory
together and have permissions set to access all the files.
What exception do you get? Error code and error message would be of
interest.

My first guess is that the proxy/stub registration is incomplete so that
when
marshaling gets necessary your calls start failing. That could be a wrong
setup
which places the proxy/stub registration into the registry of the installing
user
instead of the machine. It could be a missing registration all together and
your
other workings apps just get along because marshaling does not come into
play.

You might want to debug the line of code which throws the exception and use
ProcessMonitor http://technet.microsoft.com/en-us/s.../bb896645.aspx
to see which registry and or file system calls fail at that time. You should
monitor
w3wp.exe which hosts your ASP or ASP.NET app.

--
SvenC

Oct 16 '08 #2
The only exception that is thrown is from IIS 0x800101805 and this is only
thrown on Vista. In XP everything works as advertised with no issues, we were
able to narrow it down to the line where it creates the managed object
itself. And this only happens in Classic ASP on Vista Only. In visual basic,
visual C++ , Visual C# all execute the code normally without issues. Other
then that I am at a loss, we had a theory it might be related to permissions
to the managed assembly but we have adjusted all permissions for the IIS User
accounts on Vista giving full access rights then was going to back off to
determine what the problem was, but yet when given full Admin rights the
issue still exists.

Will continue troubleshooting today and use the tool you suggested prior to
turning the Vista machine into a boat Anchor....

"SvenC" wrote:
HI viperx1967,
We are having an issue with an application we are developing. We have
a Legacy COM DLL in C++ that we have converted to Visual Studio 2008.
This COM DLL has methods that are calling Managed C# assemblies as
pass thru to support legacy applications in an effort to move our
code to the new Code base. Our COM Object can be instantiated on
Windows XP in any COM supported environment using Visual C++, Visual
Basic, ASP.NET or ASP and works without any issues or throwing any
exceptions. When we use the object on a Vista Machine the method
fails only when it is used in a Classic ASP page. We are initializing
the Managed code in the Unmanaged code using gcroot<MYOBJ::FOOBAR^>
myObj; on the constructor, when we create an instance of the object
is when it seems to fail. We have attempted creating our instance by
using myObj = gcnew MYOBJ::FOOBAR(); in the constructor but this
caused the object to fail on CreateObject, this was moved into the
calling method. Now the object is created but now fails on the method
call. We have attempted to instanciate it using myOBJ = gcnew
MYOBJ:FOOBAR(); and gcnew MYOBJ::FOOBAR; both work in Windows XP but
do not work on Vista. All assemblies are in the same directory
together and have permissions set to access all the files.

What exception do you get? Error code and error message would be of
interest.

My first guess is that the proxy/stub registration is incomplete so that
when
marshaling gets necessary your calls start failing. That could be a wrong
setup
which places the proxy/stub registration into the registry of the installing
user
instead of the machine. It could be a missing registration all together and
your
other workings apps just get along because marshaling does not come into
play.

You might want to debug the line of code which throws the exception and use
ProcessMonitor http://technet.microsoft.com/en-us/s.../bb896645.aspx
to see which registry and or file system calls fail at that time. You should
monitor
w3wp.exe which hosts your ASP or ASP.NET app.

--
SvenC

Oct 16 '08 #3
Hi viperx1967,
The only exception that is thrown is from IIS 0x800101805 and this is
that is not a valid error code. 0x8001 should be followed by 4 digits
only. Could you please post the correct number.

Is it 0x80010108? That translates to "The object invoked has disconnected
from its clients.". For an inprocess COM object it typically tells you that
your object's code crashed..

You could use OutputDebugString in your C++ code and
System.Diagnostics.Debug.WriteLine in your managed code (remember
to build and use the debug configuration to get the Debug-Output working)
to see how far your object's code gets. Use DebugView to catch the output.
Run Debug View "As Admin" and enable Capture Global Win32 to get
output from the IIS processes.

You could attach the VS debugger to w3wp.exe as well and single step
your code. Make sure to run VS "As Admin" and attach with native and
managed debugging to debug both your native and managed code.
...we were able to narrow it down to the line where it creates
the managed object itself. And this only happens in Classic ASP on
Vista Only
You speak of running IIS on Vista and not of your browser running
on vista, correct?
In visual basic, visual C++ , Visual C# all execute the
code normally without issues. Other then that I am at a loss
It might be due to some parameter limitations in ASP which are basically
just VBScript files. So all your COM objects are used through IDispatch.
To simulate that you might want to check how your object behaves
when used in a vbs file. Just put your crashing code in a vbs file and
see if it can be executed there.

--
SvenC
Oct 16 '08 #4
Sorry my bad the error is 0x80004005 which equates to Unspecified error. In
further testing we have created a completely new COM dll and new .NET object
put the most simplistic method that returns only a string. Once again the COM
object creates the .NET assembly calls the method and returns the value
properly to ASP on Windows XP but still fails on Vista. In further research
we thought maybe it might be due to the assembly not being strongly typed and
put in the GAC, so we strongly typed the assembly and then put it in the GAC
with the same result. Works on XP fails on XP. All assemblies were installed
on the Vista Machine with the "Real" Admin not the standard Administrator
that is default. This has not helped, we are now moving to another Vista
machine in case the one we are testing on is corrupt in some manner. To
replicate the issue create a simple COM dll in C++ using ATL add a Simple
Object interface and 1 method parameters and return values not important.
Create a .Net Assembly add a method that returns a value. In the C++ COM dll
use the #using "myassembly.dll" namespace myassembly; to import the assembly
then in your COM method create an instance of the .Net assembly and call the
method on the Assembly. Our sample looks like this:
#using <mscorlib.dll>
#include <vcclr.h>
using namespace System;
#using "MyTestobject.dll"
using namespace MyTestObject;

In my Method I use:
MyTestObject::ImaTesting^ objTest = gcnew MyTestObject::ImaTesting();
System::String^ myString = objTest->ReturnMoFO("This is a Test");
CString str = CString(myString);
*bstrResult = str.AllocSysString();
return S_OK;
My Method is defined as follows:
STDMETHODIMP CTestObject::CallMe(BSTR *bstrResult)
The .NET assembly has no more code than this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MyTestObject
{
public class ImaTesting
{
public string ReturnMeMoFO(string strvalue)
{
return "*****" + strvalue + "******";
}
}
}

Not much too it but still cannot get it to work on Vista we broke it down to
the most primary functionality with both objects with no success.
"SvenC" wrote:
Hi viperx1967,
The only exception that is thrown is from IIS 0x800101805 and this is

that is not a valid error code. 0x8001 should be followed by 4 digits
only. Could you please post the correct number.

Is it 0x80010108? That translates to "The object invoked has disconnected
from its clients.". For an inprocess COM object it typically tells you that
your object's code crashed..

You could use OutputDebugString in your C++ code and
System.Diagnostics.Debug.WriteLine in your managed code (remember
to build and use the debug configuration to get the Debug-Output working)
to see how far your object's code gets. Use DebugView to catch the output.
Run Debug View "As Admin" and enable Capture Global Win32 to get
output from the IIS processes.

You could attach the VS debugger to w3wp.exe as well and single step
your code. Make sure to run VS "As Admin" and attach with native and
managed debugging to debug both your native and managed code.
...we were able to narrow it down to the line where it creates
the managed object itself. And this only happens in Classic ASP on
Vista Only

You speak of running IIS on Vista and not of your browser running
on vista, correct?
In visual basic, visual C++ , Visual C# all execute the
code normally without issues. Other then that I am at a loss

It might be due to some parameter limitations in ASP which are basically
just VBScript files. So all your COM objects are used through IDispatch.
To simulate that you might want to check how your object behaves
when used in a vbs file. Just put your crashing code in a vbs file and
see if it can be executed there.

--
SvenC
Oct 16 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: New World Order Pigs | last post by:
Sorry if this is the wrong group, but it seems like a good place to start. I have a control, creating a dll written in c#/.net and some unmanaged code in c++ using embedded c++ V3. Yes, it is for...
2
by: Paul Kenny | last post by:
Hi, I am trying to expose the functionality of an unmanaged C++ class to the other languages available in the .NET Framework. I have decided to do this by wrapping the unmanaged C++ class in a...
3
by: JoeProgrammer | last post by:
A couple of questions re. managed vs. unmanaged code. 1. I know this depends on the app, but how much faster is unmanaged code vs. managed code? Is there an average figure for this? 2. Is it as...
3
by: Tommy Svensson \(InfoGrafix\) | last post by:
I've been instructed to work againt a huge unmanaged C++ API from a C# application. Now, the only way, as I've understood it, is to go the Managed Extensions for C++ way. This means I have to...
13
by: bonk | last post by:
Hello, I am trying to create a dll that internally uses managed types but exposes a plain unmanaged interface. All the managed stuff shall be "wrapped out of sight". So that I would be able to...
12
by: doug | last post by:
I understand the basics of what managed code offers and that you open yourself up to security issues if you allow unmanaged code. We already have a decent amount of VB6 code to include COM DLLs. ...
1
by: MC-Advantica | last post by:
Does anyone have a simple "Hello World" like application that demonstrates unmanaged C++ calling managed C++ developed in VS2005? I'm confused by many posts as they discuss managed extensions from...
7
by: A n g l e r | last post by:
Hi all. Can you please tell me if you have any problems to use managed C++ DLL libraries that wrap some code from unmanaged external DLL 32 bit libraries? If you called such managed 32 bit DLL...
66
by: John | last post by:
Hi What are the advantages actually achieved of managed code? I am not talking of theory but in reality. Thanks Regards
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.