C
Chris Baldwin
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
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