473,405 Members | 2,154 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,405 software developers and data experts.

exception/Exception clash using mixed dll in VB.NET

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
Nov 17 '05 #1
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

Nov 17 '05 #2
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

Nov 17 '05 #3
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

Nov 17 '05 #4

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

Similar topics

5
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") &&...
3
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...
2
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...
1
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...
7
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...
0
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...
17
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...
35
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,...
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?
0
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...
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
Oralloy
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,...
0
jinu1996
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...
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
agi2029
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,...
0
isladogs
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...

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.