Hello,
I'm having a problem with a mixed managed/unmanaged DLL. When I
attempt to reference "Exception" in my VB.NET code, it conflicts with
some other "exception" that gets somehow gets into the assembly.
This code reproduces the issue:
#using <System.dll>
// #include <vector> is in stdafx.h
#include "stdafx.h"
namespace ExceptionClash
{
public __gc class Class1
{
public:
System::String* SayHello()
{
return S"Hello";
}
};
}
And then, ExceptionClash.Class1 is used by this VB.NET code:
Imports ExceptionClash
Public Class Test
Public Shared Sub Main()
Dim o As New Class1
Try
Dim s As String
s = o.SayHello()
Console.WriteLine(s)
Catch ex As Exception
Console.WriteLine(ex.ToString())
End Try
End Sub
End Class
The error I get is upon compilation of the VB.NET code:
C:\temp\ExceptionClash\Debug\test.vb(14) : error BC30392: 'Catch'
cannot catch t
ype 'exception' because it is not 'System.Exception' or a class that
inherits fr
om 'System.Exception'.
If I view ExceptionClass.dll in ildasm, I see a type "exception" in
the root namespace. This is conflicting with System.Exception in
VB.NET. It seems to only happen when #include <vector> is in
stdafx.h. I am not sure where this other "exception" class is coming
from.
I can work around the issue by not using "Imports ExceptionClash" or
by specifying System.Exception instead of just Exception. But, I'm
looking for some understanding or a resolution as opposed to a
workaround.
Does anyone have any insight into this issue?
Thanks in advance,
Chris 3 1783
Hi Chris,
Please look at the following reference: http://support.microsoft.com/default...b;en-us;822330
Thanks.
Ronald Laeremans
Visual C++ team
"Chris Baldwin" <ei******@hotmail.com> wrote in message
news:97**************************@posting.google.c om... Hello,
I'm having a problem with a mixed managed/unmanaged DLL. When I attempt to reference "Exception" in my VB.NET code, it conflicts with some other "exception" that gets somehow gets into the assembly.
This code reproduces the issue:
#using <System.dll> // #include <vector> is in stdafx.h #include "stdafx.h"
namespace ExceptionClash { public __gc class Class1 { public: System::String* SayHello() { return S"Hello"; } }; }
And then, ExceptionClash.Class1 is used by this VB.NET code:
Imports ExceptionClash
Public Class Test Public Shared Sub Main() Dim o As New Class1 Try Dim s As String s = o.SayHello() Console.WriteLine(s) Catch ex As Exception Console.WriteLine(ex.ToString()) End Try End Sub End Class
The error I get is upon compilation of the VB.NET code:
C:\temp\ExceptionClash\Debug\test.vb(14) : error BC30392: 'Catch' cannot catch t ype 'exception' because it is not 'System.Exception' or a class that inherits fr om 'System.Exception'.
If I view ExceptionClass.dll in ildasm, I see a type "exception" in the root namespace. This is conflicting with System.Exception in VB.NET. It seems to only happen when #include <vector> is in stdafx.h. I am not sure where this other "exception" class is coming from.
I can work around the issue by not using "Imports ExceptionClash" or by specifying System.Exception instead of just Exception. But, I'm looking for some understanding or a resolution as opposed to a workaround.
Does anyone have any insight into this issue?
Thanks in advance, Chris
Ronald,
Thanks for the link. I should've mentioned in my first post that
we're compiling with VS2002. Knowing that, any other tips?
Thanks again,
Chris
"Ronald Laeremans [MSFT]" <ro*****@online.microsoft.com> wrote in message news:<Ox**************@tk2msftngp13.phx.gbl>... Hi Chris,
Please look at the following reference: http://support.microsoft.com/default...b;en-us;822330
Thanks.
Ronald Laeremans Visual C++ team
"Chris Baldwin" <ei******@hotmail.com> wrote in message news:97**************************@posting.google.c om... Hello,
I'm having a problem with a mixed managed/unmanaged DLL. When I attempt to reference "Exception" in my VB.NET code, it conflicts with some other "exception" that gets somehow gets into the assembly.
This code reproduces the issue:
#using <System.dll> // #include <vector> is in stdafx.h #include "stdafx.h"
namespace ExceptionClash { public __gc class Class1 { public: System::String* SayHello() { return S"Hello"; } }; }
And then, ExceptionClash.Class1 is used by this VB.NET code:
Imports ExceptionClash
Public Class Test Public Shared Sub Main() Dim o As New Class1 Try Dim s As String s = o.SayHello() Console.WriteLine(s) Catch ex As Exception Console.WriteLine(ex.ToString()) End Try End Sub End Class
The error I get is upon compilation of the VB.NET code:
C:\temp\ExceptionClash\Debug\test.vb(14) : error BC30392: 'Catch' cannot catch t ype 'exception' because it is not 'System.Exception' or a class that inherits fr om 'System.Exception'.
If I view ExceptionClass.dll in ildasm, I see a type "exception" in the root namespace. This is conflicting with System.Exception in VB.NET. It seems to only happen when #include <vector> is in stdafx.h. I am not sure where this other "exception" class is coming from.
I can work around the issue by not using "Imports ExceptionClash" or by specifying System.Exception instead of just Exception. But, I'm looking for some understanding or a resolution as opposed to a workaround.
Does anyone have any insight into this issue?
Thanks in advance, Chris
VS 2002 does not have this behavior in the first place (it works as though
you would have specified /d1PrivateNativeTypes).
Can you sue ILDASM to look at the assembly you created to see exactly what
the definition of the exception object is you have in there?
VS 2002 really is not a great tool for creating MC++ applications. Is there
a specific reason why you have not upgraded to VC 2003 where many
significant issues have been fixed?
Ronald
"Chris Baldwin" <ei******@hotmail.com> wrote in message
news:97**************************@posting.google.c om... Ronald,
Thanks for the link. I should've mentioned in my first post that we're compiling with VS2002. Knowing that, any other tips?
Thanks again, Chris
"Ronald Laeremans [MSFT]" <ro*****@online.microsoft.com> wrote in message news:<Ox**************@tk2msftngp13.phx.gbl>... Hi Chris,
Please look at the following reference: http://support.microsoft.com/default...b;en-us;822330
Thanks.
Ronald Laeremans Visual C++ team
"Chris Baldwin" <ei******@hotmail.com> wrote in message news:97**************************@posting.google.c om... > Hello, > > I'm having a problem with a mixed managed/unmanaged DLL. When I > attempt to reference "Exception" in my VB.NET code, it conflicts with > some other "exception" that gets somehow gets into the assembly. > > This code reproduces the issue: > > #using <System.dll> > // #include <vector> is in stdafx.h > #include "stdafx.h" > > namespace ExceptionClash > { > public __gc class Class1 > { > public: > System::String* SayHello() > { > return S"Hello"; > } > }; > } > > > And then, ExceptionClash.Class1 is used by this VB.NET code: > > Imports ExceptionClash > > Public Class Test > Public Shared Sub Main() > Dim o As New Class1 > Try > Dim s As String > s = o.SayHello() > Console.WriteLine(s) > Catch ex As Exception > Console.WriteLine(ex.ToString()) > End Try > End Sub > End Class > > The error I get is upon compilation of the VB.NET code: > > C:\temp\ExceptionClash\Debug\test.vb(14) : error BC30392: 'Catch' > cannot catch t > ype 'exception' because it is not 'System.Exception' or a class that > inherits fr > om 'System.Exception'. > > If I view ExceptionClass.dll in ildasm, I see a type "exception" in > the root namespace. This is conflicting with System.Exception in > VB.NET. It seems to only happen when #include <vector> is in > stdafx.h. I am not sure where this other "exception" class is coming > from. > > I can work around the issue by not using "Imports ExceptionClash" or > by specifying System.Exception instead of just Exception. But, I'm > looking for some understanding or a resolution as opposed to a > workaround. > > Does anyone have any insight into this issue? > > Thanks in advance, > Chris This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paul Brun |
last post by:
|
by: Tony Cheng |
last post by:
for (int i=0; i<_request.Form.Count; i++ )
{
string key = _request.Form.GetKey(i);
if ( !key.Equals("formCode")
&& !key.Equals("formLanguage")
&& !key.Equals("__VIEWSTATE")
&&...
|
by: Sean Tynan |
last post by:
I want to find out the best way for a method to notify calling code of
situations such as validation errors, etc. that may occur during method
execution.
e.g. say I have a method (business...
|
by: Deepa K |
last post by:
Hi,
In my PC, eth0 is not up because of IP address clash (another PC is
using the same IP address). I tried to execute a file which has set
of insert commands. After executing the file, when I go...
|
by: David Gaudine |
last post by:
(This is a bit like the recent thread "PHP Switching Sessions".)
I use session_start(). When I open my web-based application in two windows
on the same system, there's a definite clash; I can't...
|
by: Søren Dreijer |
last post by:
Hi,
I have a mixed C#, managed C++ and unmanaged C++ project.
The managed class calls a method which exists in an unmanaged singleton
class. During the entire lifetime of the application, this...
|
by: smoothkriminal1 |
last post by:
the question is u read timetable of 40 students from file n den find da slot where all fourty students dnt hve clash...if any....
may b i ll be able to make clash logic but i m even just nt...
|
by: Cramer |
last post by:
I plan to implement an exception logging feature in an ASP.NET Web
application that writes encountered exceptions to disk. The exception data
will be stored as XML.
I am planning on having each...
|
by: eliben |
last post by:
Python provides a quite good and feature-complete exception handling
mechanism for its programmers. This is good. But exceptions, like any
complex construct, are difficult to use correctly,...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |