Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2004

Tip: Looking for answers? Try searching our database.

exception/Exception clash using mixed dll in VB.NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Baldwin - 19 Oct 2004 18:14 GMT
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 Laeremans [MSFT] - 19 Oct 2004 20:57 GMT
Hi Chris,

Please look at the following reference:
http://support.microsoft.com/default.aspx?scid=kb;en-us;822330

Thanks.

Ronald Laeremans
Visual C++ team

> Hello,
>
[quoted text clipped - 60 lines]
> Thanks in advance,
> Chris
Chris Baldwin - 20 Oct 2004 15:46 GMT
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

> Hi Chris,
>
[quoted text clipped - 70 lines]
> > Thanks in advance,
> > Chris
Ronald Laeremans [MSFT] - 22 Oct 2004 00:36 GMT
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

> Ronald,
>
[quoted text clipped - 78 lines]
>> > Thanks in advance,
>> > Chris

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.