title: C# app can't find types from a VB class library
body: <p>I'm using a commercial C# application which is designed to allow the use of external plug-ins that the app loads at runtime. Basically, you create a class library that inherits and extends certain classes from the base app, and place your DLL in a specified place where the main app looks for it.  Most plug-ins written for this app use C# however I want to use VB instead, and I think this should be possible.</p>
  
  <p>However, I get the following exceptions in the error log of the app:</p>
  
  <blockquote>
    <p>AssemblyLoader: Exception loading 'Thingamajig': 
    System.Reflection.ReflectionTypeLoadException: The classes in the
    module cannot be loaded.</p>
    
    <p>at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes
    (bool)</p>
    
    <p>at System.Reflection.Assembly.GetTypes () [0x00000] in :0 </p>
    
    <p>at AssemblyLoader.LoadAssemblies () [0x00000] in :0 </p>
    
    <p>Additional information about this exception:</p>
    
    <p>System.TypeLoadException: Could not load type
    'Thingamajig.My.MyProject' from assembly 'Thingamajig,
    Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.</p>
    
    <p>System.TypeLoadException: Could not load type
    'Thingamajig.My.MyProject+ThreadSafeObjectProvider`1[T]' from assembly
    'Thingamajig, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.</p>
    
    <p>System.TypeLoadException: Could not load type 'MyWebServices' from
    assembly 'Thingamajig, Version=1.0.0.0, Culture=neutral,
    PublicKeyToken=null'.</p>
    
    <p>System.TypeLoadException: Could not load type
    'System.Configuration.ApplicationSettingsBase' from assembly 'System,
    Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.</p>
    
    <p>System.IO.FileNotFoundException: Could not load file or assembly
    'Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.</p>
    
    <p>File name: 'Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a'</p>
  </blockquote>
  
  <p>"Thingamajig" is the name of my VB class. Both the C# app and the VB class reference .NET 3.5</p>
  
  <p>I'm an amateur programmer, so go easy on me please. I <em>think</em> what is happening is my class library is referencing certain types (Ex: My.MyProject, System.Configuration.ApplicationSettingsBase, MyWebServices) that the main app cannot find. I tried to add a reference to Microsoft.VisualBasic in the class library but Visual Studio comes back with an error stating that this component is "already automatically referenced by the build system".  My code for this "test" is very simple:</p>
  
  <pre><code>Imports System
  Imports UnityEngine
  
  Public Class Thingamajig
      Inherits PartModule
      Private _windowPosition As New Rect()
  
      Public Overrides Sub OnStart(state As StartState)
          If state &lt;&gt; StartState.Editor Then
              RenderingManager.AddToPostDrawQueue(0, AddressOf ondraw)
          End If
      End Sub
  
      Private Sub ondraw()
          If Me.vessel.active Then
              _windowPosition = GUILayout.Window(10, _windowPosition, AddressOf onwindow, "Hello World")
          End If
      End Sub
  
      Private Sub onwindow(windowid As Integer)
          GUILayout.BeginHorizontal(GUILayout.Width(250.0F))
          GUILayout.Label("WOW! Isn't this Amazing?")
          GUILayout.EndHorizontal()
          GUI.DragWindow()
  
      End Sub
  
  End Class
  </code></pre>
  
  <p>Any ideas how to proceed?  Can I exclude the problematic types from the class library, or somehow tell the C# app where to find them?  Or, is what I am trying to do simply not possible?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>The answer below (compiling outside of the VS IDE) worked for my sample code that didn't really do much. Then I added some external libraries, one of which requires Newtonsoft.Json.dll.  I referenced that DLL during compilation and it compiles fine but when I run the app I get this in the log: 
   System.TypeLoadException: Could not load type 'Newtonsoft.Json.Converters.StringEnumConverter' from assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.</p>
  
  <p>System.TypeLoadException: Could not load type 'Newtonsoft.Json.Converters.XObjectWrapper' from assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.</p>
  
  <p>System.TypeLoadException: Could not load type 'Newtonsoft.Json.Linq.Extensions' from assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.</p>
  
  <p>Is this the same issue?  If i compile with Newtonsoft, why am I getting these errors?</p>