[mono-vb] Creating instance of VB assembly in native linux c application

Rafael Teixeira monoman at gmail.com
Mon Aug 14 10:08:55 EDT 2006


inline

On 8/14/06, Alex Sisson <alexs at callview.com> wrote:
> Hi
>
> Thanks for the reply.
>
> Was checking the refences in the VS object browser and noticed that the VB DLL namespace was shown
> as VBDLL.SWAN   (VBDLL is the project, SWAN was my namespace), where as in the C# DLL the name space
> was just shown as SWAN.
>
> I was calling mono_class_from_name with the name_space parameter as SWAN - changing this to VBDLL.SWAN for the
> vb dll made it work.
>
> This seems a little inconsistent, so not sure if VS is doing something wrong by prefixing the project to the namespace for VB assemblies.

>From what I remember of VS.NET (some years ago), this is a project
setting, but the default for VB projects, really is for the root
namespace to be the project name, and IS inconsistent with the
behaviour for C# projects.

vbc has a command-line option for that the VB project builder of VS.NET uses:

 /rootnamespace:namespace

See:
.NET 1.x
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/valrfRootnamespace.asp
.NET 2
http://msdn2.microsoft.com/en-us/library/58kxttdx.aspx

As to understand a bit of the internals of VS.NET on that regard:
http://msdn2.microsoft.com/en-us/library/vslangproj.projectproperties.rootnamespace.aspx

And a bad opinion on it:
http://hyperthink.net/blog/2004/08/14/RootNamespace+In+VBNET.aspx

:)
> Anyway, cheers
> Alex
>
>
> -----Original Message-----
> From: Rafael Teixeira [mailto:monoman at gmail.com]
> Sent: 14 August 2006 13:59
> To: Alex Sisson
> Cc: mono-vb at lists.ximian.com
> Subject: Re: [mono-vb] Creating instance of VB assembly in native linux
> c application
>
>
> Never heard of someone trying to call VB.NET assembly from C by embedding Mono.
>
> Have you tried to call the methods from C# instead of from C?
>
> Also, check that you didn't compile them with incremental linking
> (default on debug builds) as it puts an undocumented segment within
> the assembly, that prevents Mono from loading the assembly.
>
> Possible culprits, if both tests above pass OK:
> ++ vbc (the compiler that VS.NET calls) may generate assemblies with
> some undocumented characteristic, that Mono doesn't know how to deal
> (if such we wan't to know to implement it)
> ++ some support code in mono's implementation
> Microsoft.VisualBasic.dll, doesn't work as needed (doesn't seem to be
> it, but alas)
>
> Could you open a bugzilla case with details, and a short VB.NET
> assembly that causes the problem (the snippet of code that do your
> embedded calling)?
>
> Thanks,
>
> On 8/14/06, alexs <alexs at callview.com> wrote:
> >
> > Hi all,
> >
> > I'm investigating mono so that we can avoid rewriting VB.NET assemblies  for
> > a possible linux port of our software...
> >
> > I have created a simple VB.NET assembly with static and instance methods and
> > compile is in Visual Studio. On Linux in c, I can load the assembly, and
> > invoke the static methods no problems. But when I try and create an
> > instance, it fails - well, "mono_class_from_name" is what fails (I'm using
> > the right namespace and class name!)...
> >
> > If I recreate the  assembly in C# with the same methods, and compile again
> > on VS, I can create an instance of it no problems in linux, and can call an
> > instance method.
> >
> > Does anyone have an ideas as to why this could be?
> >
> > Thanks
> > Alex
> > --
> > View this message in context: http://www.nabble.com/Creating-instance-of-VB-assembly-in-native-linux-c-application-tf2102633.html#a5794595
> > Sent from the Mono - VB forum at Nabble.com.
> >
> > _______________________________________________
> > Mono-vb mailing list
> > Mono-vb at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-vb
> >
>
>
> --
> Rafael "Monoman" Teixeira
> ---------------------------------------
> "The reasonable man adapts himself to the world; the unreasonable one
> persists in trying to adapt the world to himself. Therefore all
> progress depends on the unreasonable man." George Bernard Shaw
>
>
> This message has been scanned for viruses by MailController - www.MailController.altohiway.com
>


-- 
Rafael "Monoman" Teixeira
---------------------------------------
"The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man." George Bernard Shaw


More information about the Mono-vb mailing list