473,811 Members | 3,057 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.WriteLi ne(s)
Catch ex As Exception
Console.WriteLi ne(ex.ToString( ))
End Try
End Sub
End Class

The error I get is upon compilation of the VB.NET code:

C:\temp\Excepti onClash\Debug\t est.vb(14) : error BC30392: 'Catch'
cannot catch t
ype 'exception' because it is not 'System.Excepti on' or a class that
inherits fr
om 'System.Excepti on'.

If I view ExceptionClass. dll in ildasm, I see a type "exception" in
the root namespace. This is conflicting with System.Exceptio n 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.Exceptio n 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 1798
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******@hotma il.com> wrote in message
news:97******** *************** ***@posting.goo gle.com...
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.WriteLi ne(s)
Catch ex As Exception
Console.WriteLi ne(ex.ToString( ))
End Try
End Sub
End Class

The error I get is upon compilation of the VB.NET code:

C:\temp\Excepti onClash\Debug\t est.vb(14) : error BC30392: 'Catch'
cannot catch t
ype 'exception' because it is not 'System.Excepti on' or a class that
inherits fr
om 'System.Excepti on'.

If I view ExceptionClass. dll in ildasm, I see a type "exception" in
the root namespace. This is conflicting with System.Exceptio n 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.Exceptio n 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******* *******@tk2msft ngp13.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******@hotma il.com> wrote in message
news:97******** *************** ***@posting.goo gle.com...
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.WriteLi ne(s)
Catch ex As Exception
Console.WriteLi ne(ex.ToString( ))
End Try
End Sub
End Class

The error I get is upon compilation of the VB.NET code:

C:\temp\Excepti onClash\Debug\t est.vb(14) : error BC30392: 'Catch'
cannot catch t
ype 'exception' because it is not 'System.Excepti on' or a class that
inherits fr
om 'System.Excepti on'.

If I view ExceptionClass. dll in ildasm, I see a type "exception" in
the root namespace. This is conflicting with System.Exceptio n 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.Exceptio n 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 /d1PrivateNative Types).

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******@hotma il.com> wrote in message
news:97******** *************** ***@posting.goo gle.com...
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******* *******@tk2msft ngp13.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******@hotma il.com> wrote in message
news:97******** *************** ***@posting.goo gle.com...
> 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.WriteLi ne(s)
> Catch ex As Exception
> Console.WriteLi ne(ex.ToString( ))
> End Try
> End Sub
> End Class
>
> The error I get is upon compilation of the VB.NET code:
>
> C:\temp\Excepti onClash\Debug\t est.vb(14) : error BC30392: 'Catch'
> cannot catch t
> ype 'exception' because it is not 'System.Excepti on' or a class that
> inherits fr
> om 'System.Excepti on'.
>
> If I view ExceptionClass. dll in ildasm, I see a type "exception" in
> the root namespace. This is conflicting with System.Exceptio n 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.Exceptio n 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
2853
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") && !key.Equals("__EVENTARGUMENT") && !key.Equals("__EVENTTARGET") && key.IndexOf("sendButton")<0 && key.IndexOf("clearButton")<0
3
2740
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 logic layer) that inserts a user into a database, and returns the newly created UserID: public function CreateUser(userName as string, userEmail as string) dim userID as integer
2
2254
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 and see the database, no rows are inserted. I redirected the output to another file. It shows success for all inserts, but no rows in database. This is happening only when the PC has IP clash, that too not all times. I wasn't able to trace out...
1
3458
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 do two independent sessions because the session variables are shared. I solved that the easy way, by not opening two windows. But then I went on to write more applications, and found that if I use the same variable names (for session variables)...
7
9546
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 gives no problems whatsoever. However, upon shutdown an exception pops up: "The string binding is invalid" If I call the singleton method from inside a purely unmanaged class, I
0
1348
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 getting how to pick timetable data from file using linklist file can b of any format there shud b six days n 6 lecture a day(maximum) plz help me for coding this problem
17
2756
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 exception written to its own XML file. I plan to NOT append exceptions to a single XML file because I don't want for the exception logging component to have to deal with contention for access to the file. This is possible when, for example,...
35
3524
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, especially as programs get large. Most of the issues of exceptions are not specific to Python, but I sometimes feel that Python makes them more acute because of the free-n- easy manner in which it employs exceptions for its own uses and allows users...
0
9726
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10647
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10395
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9204
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5553
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4338
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.