[Mono-dev] VBNC and embedding

Andreas Färber andreas.faerber at web.de
Sat Aug 1 04:35:07 EDT 2009


Am 01.08.2009 um 02:38 schrieb bassraf at gmail.com:

> 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";
> 	m_Params.ReferencedAssemblies.Clear();
> 	m_Params.ReferencedAssemblies.Add("mscorlib.dll");
> 	
> 	CodeDomProvider m_Provider = new  
> Microsoft.VisualBasic.VBCodeProvider();
> 	CompilerResults cResults =  
> m_Provider.CompileAssemblyFromSource(m_Params, Script);
[...]
> Here's the (VB) script I'm trying to compile:
>
> imports System
> imports System.Windows.Forms
>
> Namespace xpScript
>
> Class ScriptObject
>
> Public Sub Main()
>  MessageBox.Show("hello?")
> End Sub
>
> End Class
>
> End Namespace

> [...] 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.

I'd be surprised if such code compiled in any language without  
referencing the System.Windows.Forms assembly in your m_Params...  
Obviously shouldn't crash the compiler though.

Andreas



More information about the Mono-devel-list mailing list