Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 400611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:57:26+00:00 2026-05-12T16:57:26+00:00

I am having difficulty dynamically compiling a DLL for use with Silverlight 3.0. My

  • 0

I am having difficulty dynamically compiling a DLL for use with Silverlight 3.0. My goal is to take some rules provided by my users and compile them into a DLL for custom editing purposes.

I created a Silverlight class library project in Visual Studio to get the command line for compiling a Silverlight class library. Based on that and the many examples for compiling VB using the VBCodeProvider, I came up with the following method for comping code in a string to a DLL:

Public Function Compile(ByVal code As String, ByVal assemblyName As String) As CompilerResults
    ' set the compiler parameters
    Dim parameters As CompilerParameters = New CompilerParameters()
    parameters.OutputAssembly = assemblyName
    parameters.GenerateInMemory = False
    parameters.GenerateExecutable = False
    parameters.IncludeDebugInformation = True

    ' constants for the silverlight assembly directories
    Dim sdkDir As String = "c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v3.0\"
    Dim clientDir As String = "c:\Program Files (x86)\Microsoft SDKs\Silverlight\v3.0\Libraries\Client\"
    Dim riaDir As String = "C:\Program Files (x86)\Microsoft SDKs\RIA Services\v1.0\Libraries\Silverlight\"

    ' set referenced assemblies
    parameters.ReferencedAssemblies.Clear()
    parameters.ReferencedAssemblies.Add(sdkDir + "mscorlib.dll")
    parameters.ReferencedAssemblies.Add(sdkDir + "System.Core.dll")
    parameters.ReferencedAssemblies.Add(sdkDir + "system.dll")
    parameters.ReferencedAssemblies.Add(sdkDir + "System.Net.dll")
    parameters.ReferencedAssemblies.Add(sdkDir + "System.Windows.Browser.dll")
    parameters.ReferencedAssemblies.Add(sdkDir + "System.Windows.dll")
    parameters.ReferencedAssemblies.Add(sdkDir + "System.Xml.dll")

    ' build compiler options for sdk path to point to Silverlight.
    Dim options As String

    options = "/sdkpath:""" + sdkDir + "\"" "
    options = options + "/define:""SILVERLIGHT=1"""

    parameters.CompilerOptions = options

    ' compile
    Dim provider = New VBCodeProvider()
    Return provider.CompileAssemblyFromSource(parameters, code)
End Function

My unit test class that code as follows:

Public Sub CompileTest()

    ' Assemble
    Dim builder As StringBuilder = New StringBuilder()
    builder.AppendLine("Imports System")
    builder.AppendLine("Namespace Namespace1")
    builder.AppendLine("Public Class Class1")
    builder.AppendLine("Public Sub Test()")
    builder.AppendLine("Console.WriteLine(""Hello Compilation"")")
    builder.AppendLine("Console.ReadLine()")
    builder.AppendLine("End Sub")
    builder.AppendLine("End Class")
    builder.AppendLine("End Namespace")

    Dim assemblyName As String = ".\TestAssembly.dll"

    ' Act
    Dim compiler As SilverlightCompiler = New SilverlightCompiler()
    Dim cr As CompilerResults = compiler.Compile(builder.ToString(), assemblyName)

    ' Assert
    Assert.AreEqual(0, cr.Errors.Count)
End Sub

This does not compile with the following error:

vbc : Command line (0,0) : error BC2010: compilation failed : ‘Member ‘IsNumeric’ cannot be found in class ‘Microsoft.VisualBasic.Information’. This condition is usually the result of a mismatched ‘Microsoft.VisualBasic.dll’.’

I’ve looked and, in fact, the Silverlight version of the class Microsoft.VisualBasic.Information does not contain member IsNumeric. So I appear to be picking up the correct libraries using the sdkpath option. But I have no idea why I’m trying to call that method in the first place.

Can anyone shed light on how to successfully compile source code dynamically into a Silverlight compatible class library? TIA.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:57:26+00:00Added an answer on May 12, 2026 at 4:57 pm

    Found the answer by getting the code provider to save the temp files it was creating. This is done my adding:

        parameters.TempFiles.KeepFiles = True
    

    to the compiler options.

    When this was done, the vbc command line and the code it compiled was left behind in my user temp directory. Looking at it, I could see I was using the vbc compiler in the .Net 2.0 directory, not the 3.5 directory.

    In order to get it to use the compiler in the 3.5 directory, the lines under the ‘Compile comment were changed to the following:

        ' compile
        Dim languageOptions As Dictionary(Of String, String) = New Dictionary(Of String, String)()
        languageOptions("CompilerVersion") = "v3.5"
    
        Dim provider = New VBCodeProvider(languageOptions)
        Return provider.CompileAssemblyFromSource(parameters, code)
    

    It uses an overload on the VBCodeProvider constructor that takes language options. A co-worker found this using Reflector on the T4 template engine; later I found it documented in an example here:

    http://msdn.microsoft.com/en-us/library/bb470844.aspx

    Once this was set properly, the code compiled.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 196k
  • Answers 196k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Workflow would be a good fit for all process related… May 12, 2026 at 7:11 pm
  • Editorial Team
    Editorial Team added an answer There's no generic solution for this, because I could write… May 12, 2026 at 7:11 pm
  • Editorial Team
    Editorial Team added an answer Lucene comes with a stemmer called "Lucene SnowBall stemmer' (http://lucene.apache.org/java/2_4_0/api/contrib-snowball/index.html).… May 12, 2026 at 7:11 pm

Related Questions

I am using Linq To XML to create XML that is sent to a
I am having difficulty reliably creating / removing event sources during the installation of
I am having difficulty determining if the body of a text email message is
I am having difficulty writing a Stored Procedure that will query a list of
I am having difficulty using a thirdparty library registration function to register a callback.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.