[Mono-dev] VBNC and embedding
bassraf at gmail.com
bassraf at gmail.com
Fri Jul 31 20:38:00 EDT 2009
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 below:
I'm on Windows XP, VS2005, mono 18.104.22.168 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 Microsoft.VisualBasic.VBCodeProvider();
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:
Public Sub Main()
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 compile.
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-list-
> 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 code
> > provider will always give me VBNC_CRASH at line 0 as an error result
> > when trying to compile a very basic piece of VB.NET code. All I do is
> > switch the code provider (and the script code obviously).
> > Is there anyone who is using the VBCodeProvider under the 2.x runtime
> > successfully that can tell me what’s 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.
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
More information about the Mono-devel-list