Could not load file or assembly 'TranslationFormsApplication.TranslationForm.SavedData>' or one of its dependencies

0

I got that error

Could not load file or assembly 'TranslationFormsApplication.TranslationForm.SavedData>' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)

when I debug my code in C#. The SavedData is a class name inside another class.

Below is the sample code

namespace TranslationFormsApplication 
{  
   partial class TranslationForm 
   { 
       private class SavedData 
       { 
          public SavedData(int id, string s, string t) 
          { 
             index = id; 
             source = s; 
             translation = t; 
          } 
          private int m_index; 
          public int index { get { return m_index; } set { m_index = value; } 
       } 
   } 
}

The error stack when I tried to open the form designer looks like this:

at System.IO.Path.CheckInvalidPathChars(String path)
at System.IO.Path.Combine(String path1, String path2)
at Microsoft.VisualStudio.Platform.VsAppDomainManager.d__1.MoveNext()
at Microsoft.VisualStudio.Platform.VsAppDomainManager.InnerResolveHandler(String name)
at Microsoft.VisualStudio.Platform.VsAppDomainManager.ResolveHandler(Object sender, ResolveEventArgs args)
at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)

I looked at the x86/Debug/ folder and there is indeed no TranslationFormsApplication.TranslationForm.SavedData file.

Since I use Windows 7, I know we're supposed to clean the temporary ASP.net files in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\ And all other versions and also in C:\Windows\Microsoft.NET\Framework\ And also in C:\Users\Username\AppData\Tmp\

I have done that, actually there is no "Temporary ASP.NET Files" that I can find of. I have also deleted the bin/Debug and obj86/Debug folder but it doesn't help.

All the access to the class are done inside the TranslationForm class. Below are the examples:

private Dictionary textIndexes;

    private void InitializeComponent()
    {

             this.textIndexes = new Dictionary<int,SavedData>();
    }   

    private void accept_Click(object sender, System.EventArgs e)
    {
        SavedData data;
        if (textIndexes.ContainsKey(selectedIndex))
        {
            data = textIndexes[selectedIndex];
            data.source = sourceEdit.Text;
            data.translation = transEdit.Text;            
        }
        else
        {
            data = new SavedData(selectedIndex, sourceEdit.Text, transEdit.Text);
            textIndexes.Add(selectedIndex, data);
        }
    } 

    private void saveTrainingFiles()
    {
        foreach (KeyValuePair<int, SavedData> line in textIndexes)
        {
             SavedData data = line.Value;

              sw.WriteLine(data.source);
              sw2.WriteLine(data.translation);
        }
        textIndexes.Clear();
    }

When I changed the code to use tuple instead of class SavedData, I got the following warning:

Warning 1 The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

The error stack when I tried to open FormDesigner is:

1.   Hide Call Stack 

at System.Reflection.AssemblyName.nInit(RuntimeAssembly& assembly, Boolean forIntrospection, Boolean raiseResolveEvent)
at System.Reflection.AssemblyName..ctor(String assemblyName)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, ReferenceType refType)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetRuntimeType(String typeName)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetType(String typeName)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.GetType(String typeName)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.GetType(IDesignerSerializationManager manager, String name, Dictionary`2 names)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.FillStatementTable(IDesignerSerializationManager manager, IDictionary table, Dictionary`2 names, CodeStatementCollection statements, String className)
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at   Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at   Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload)  

I guess it has something to do with the versioning of .NET and also using 64 bit machine. Any idea how to resolve it with and without using the class?

c#
class
.net-assembly
asked on Stack Overflow Dec 20, 2011 by lita • edited Dec 22, 2011 by Jeff LaFay

1 Answer

0

[SavedData class should be public to be accessed like TranslationFormsApplication.TranslationForm.SavedData

public class SavedData

[UPDATE]:

On another note, shouldn't your code be:

namespace TranslationFormsApplication 
{  
partial class TranslationForm 
{ 
   public class SavedData 
   { 
      public SavedData(int id, string s, string t) 
      { 
         index = id; 
         source = s; 
         translation = t; 
      } 
      private int m_index; 
      private string m_source; 
      private string m_translation; 

       public int index { get { return m_index; } set { m_index = value; } }
       public string source { get { return m_source; } set { m_source = value; } }
       public string translation { get { return m_translation; } set { m_translation = value; } }
   } 
} 
}
answered on Stack Overflow Dec 20, 2011 by Azhar Khorasany • edited Dec 21, 2011 by Azhar Khorasany

User contributions licensed under CC BY-SA 3.0