[Mono-dev] VBNC and embedding
Rolf Bjarne Kvinge
rolflists at ya.com
Sat Aug 1 05:08:37 EDT 2009
A couple of debugging hints I'd try:
Use Console.WriteLine instead of MessageBox
Modify the vbnc script (which calls the vbnc.exe executable) to dump
compiler parameters / code to a file and try to reproduce executing vbnc
> -----Original Message-----
> From: mono-devel-list-bounces at lists.ximian.com [mailto:mono-devel-list-
> bounces at lists.ximian.com] On Behalf Of bassraf at gmail.com
> Sent: sábado, 01 de agosto de 2009 2:38
> To: 'Robert Jordan'; 'mono-devel-list at lists.ximian.com'
> Subject: Re: [Mono-dev] VBNC and embedding
> Robert, may I be so blunt to ask which steps you take exactly to
> successfully get VB code to compile?
> I'm doing nothing too complicated, but the code is spread over multiple
> classes, so what I'll do is paint a picture of what I'm currently doing
> I'm on Windows XP, VS2005, mono 22.214.171.124 and using the embedding API.
> I load, "libglib-2.0-0.dll" and "mono.dll" and get a whole bunch of
> procaddresses from mono.dll.
> m_RootDomain = mono_jit_init_version("root","v2.0.50727");
> m_MainAssembly = mono_assembly_open(&m_MainAssemblyFile);
> m_MainImage = mono_assembly_get_image(m_MainAssembly);
> The main assembly contains the "compiler" code which I will be calling
> from the unmanaged code using the embedding API:
> CompilerParameters m_Params = new CompilerParameters();
> m_Params.GenerateExecutable = false;
> m_Params.GenerateInMemory = true;
> m_Params.IncludeDebugInformation = false;
> m_Params.TreatWarningsAsErrors = false;
> m_Params.CompilerOptions = "/t:library";
> CodeDomProvider m_Provider = new
> CompilerResults cResults =
> m_Provider.CompileAssemblyFromSource(m_Params, Script);
> Which I call using: mono_runtime_invoke();
> Here's the (VB) script I'm trying to compile:
> imports System
> imports System.Windows.Forms
> Namespace xpScript
> Class ScriptObject
> Public Sub Main()
> End Sub
> End Class
> End Namespace
> I tried loading a 2.0 assembly using mono_jit_init(), (to make sure the
> switching to 2.0 works) but same result.
> If I force loading of v1.0 or v9.0 for example, the call to the managed
> compiler simply hangs in the MSVC debugger.
> But when I do the above (correctly switch to 2.0) I get the VBNC_CRASH
> error in the compiler results.
> The weird thing is that when I switch the CodeProvider to
> CSharpProvider it works beautifully and I can compile AND execute
> just about any code, using the VBCodeProvider the "script" won't even
> Do you see any obvious ommisions or mistakes in the above?
> You wouldn't happen to have a very basic working msvc solution which
> simply loads an assembly and executes a VBScript do you?
> Thanks for you help,
> > -----Original Message-----
> > From: mono-devel-list-bounces at lists.ximian.com [mailto:mono-devel-
> > bounces at lists.ximian.com] On Behalf Of Robert Jordan
> > Sent: Friday, July 31, 2009 17:01 P
> > To: mono-devel-list at lists.ximian.com
> > Subject: Re: [Mono-dev] VBNC and embedding
> > bassraf at gmail.com wrote:
> > > Hi guys,
> > >
> > > I have successfully integrated mono as scripting engine using
> > > CSharpCodeProvider and the embedding api. However, ever since mono
> > > 2.0, switching to Microsoft.VisualBasic.VBCodeProvider() as the
> > > provider will always give me VBNC_CRASH at line 0 as an error
> > > when trying to compile a very basic piece of VB.NET code. All I do
> > > switch the code provider (and the script code obviously).
> > >
> > > Is there anyone who is using the VBCodeProvider under the 2.x
> > > successfully that can tell me whats going on?
> > It works fine for me when I'm trying to compile some basic
> > VB code.
> > Are you sure that you're switching the runtime correctly to run
> > on the 2.0 profile? VBCodeProvider does not support .NET 1.1.
> > Robert
> > _______________________________________________
> > Mono-devel-list mailing list
> > Mono-devel-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-devel-list
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
More information about the Mono-devel-list