문제

I m trying to run an older vb.net code but it breaks with this error (exception System.Reflection.TargetInvocationException). Here's the tracelog:

   Source="mscorlib"   StackTrace:
   à System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)
   à System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
   à System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
   à System.Runtime.Serialization.ObjectManager.DoFixups()
   à System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
   à System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
   à System.Resources.ResourceReader.DeserializeObject(Int32 typeIndex)
   à System.Resources.ResourceReader.LoadObjectV2(Int32 pos, ResourceTypeCode& typeCode)
   à System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase, Boolean isString)
   à System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream)
   à JMF.MDIContainer.InitializeComponent() dans C:\JMF\SOURCES\JMF\Menu.vb:ligne 160
   à JMF.MDIContainer..ctor() dans C:\JMF\SOURCES\JMF\Menu.vb:ligne 73
   à JMF.MDIContainer.Main() dans C:\JMF\SOURCES\JMF\Menu.vb:ligne 187
   à System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   à System.Threading.ThreadHelper.ThreadStart()

The line #160 performs this task Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)

I think the error is due to this line cause when I comment it, everything runs well. How can I fix this?

도움이 되었습니까?

해결책

This is the expression within the statement which is causing the problem

resources.GetObject("ImageList1.ImageStream")

Based on the stack trace it appears there is something wrong with the ImageList1.ImageStream resource. It exists but the deserialization code isn't able to handle it properly.

It's hard to say without seeing the actual resource what the problem is. My first step would be to simply load up the resource in Visual Studio and see if it's corrupted. If not try replacing it with a stock image list and see if the problem goes away (would indicate a bad resource)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top