我得到的錯誤無法加載文件或程序集「TranslationFormsApplication.TranslationForm.SavedData>」或一個依賴
的一個無法加載文件或程序集 「TranslationFormsApplication.TranslationForm.SavedData>」或之一其 依賴關係。該參數不正確。 (從HRESULT異常:。 80070057(E_INVALIDARG)
,當我在C#調試我的代碼SavedData是另一個類中的類名
下面是示例代碼
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; }
}
}
}
當我嘗試打開窗體設計器時出現錯誤堆棧,如下所示:
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 lo在x86/Debug /文件夾中出現,並且確實沒有TranslationFormsApplication.TranslationForm.SavedData文件。因爲我使用的是Windows 7,我知道我們應該清理臨時ASP.net文件 C:\ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ Temporary ASP.NET Files \ 而所有其它版本 並在 C:\ WINDOWS \ Microsoft.NET \框架\ 而且也 C:\ Users \用戶名\ AppData \ TMP \
我已經做了,居然沒有任何「臨時ASP .NET文件「,我可以找到。我也刪除了bin/Debug和obj86/Debug文件夾,但它沒有幫助。
對該類的所有訪問均在TranslationForm類中完成。下面是例子:
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();
}
當我更改爲使用元組,而不是類SavedData的代碼,我得到了以下警告:
警告1給定的程序集名稱或基本代碼無效。 (異常來自HRESULT:0x80131047)
當我試圖打開FormDesigner錯誤堆棧:
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)
我猜它是與.NET程序的版本,也使用的是64位機。任何想法如何使用和不使用類來解決它?
>命名空間TranslationFormsApplication > { > 代碼:部分類TranslationForm { 私有類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; } } } } – lita 2011-12-20 14:20:51
感謝Reniuz編輯它,我把4個空格,但它不斷抱怨,我想我也需要4個空格的錯誤堆棧,我刪除了代碼和錯誤堆棧。 – lita 2011-12-20 14:37:06
可能重複[無法加載文件或程序集的App_Licenses](http://stackoverflow.com/questions/3831287/could-not-load-file-or-assembly-app-licenses) – 2011-12-21 11:13:49