我在看《.NET 框架程序设计》看到卸载应用程序域的时候想试一试书上的代码,可是很奇怪,一样的代码我执行总要抱错
==================================================
未处理的“System.IO.FileNotFoundException”类型的异常出现在 mscorlib.dll 中。其他信息: 找不到文件或程序集名称“ConsoleApplication2, Version=1.0.2173.38435, Culture=neutral, PublicKeyToken=null”,或找不到它的一个依赖项。
==================================================
我很迷惑,什么造成上面的错误的,那位能解答一下,谢谢,你们可以试一试这段程序
==================================================
Imports System.Threading
Imports System.Reflection
Class App
    Shared Sub Main()
        Dim da As AppDomain = AppDomain.CreateDomain("MyNewAppDomain", Nothing, Nothing)
        Dim mbrt As MarshalByRefType = DirectCast(da.CreateInstanceFromAndUnwrap([Assembly].GetCallingAssembly.FullName, "MarshalByRefType"), MarshalByRefType)
        mbrt.SomeMethod(Thread.GetDomain.FriendlyName)
        AppDomain.Unload(da)
        Try
            mbrt.SomeMethod(Thread.GetDomain.FriendlyName)
        Catch ex As Exception
            Console.WriteLine(ex.ToString)
            Console.ReadLine()
        End Try
    End SubEnd classPublic Class MarshalByRefType
    Inherits MarshalByRefObject
    Public Sub SomeMethod(ByVal sourceAppDomain As String)
        Console.WriteLine("Code From {0}", sourceAppDomain)
        Console.WriteLine("Current AppDomain Is {0}", System.Threading.Thread.GetDomain.FriendlyName)
    End Sub
End Class

解决方案 »

  1.   

    应该不是D版的问题吧,呵呵~~不知道有没有哪位做过.net remoting,要是做过的话,应该对这个比较清楚~~
      

  2.   

    http://blogs.msdn.com/brada/archive/2003/04/16/49974.aspx
      

  3.   

    http://www.google.com/search?q=%22Application+Domain+FAQ%22+FileNotFoundException&btnG=%E6%90%9C%E7%B4%A2&hl=zh-CN&newwindow=1
      

  4.   

    http://www.google.com/search?q=%22Application+Domain%22+%22FileNotFoundException%22+&hl=zh-CN&newwindow=1
    Wish it will helpful for you!
      

  5.   

    它是不是还有其他的dll你没引进来