IT Share you

System.InvalidOperationException : 임시 클래스를 생성 할 수 없습니다 (result = 1).

shareyou 2020. 11. 29. 12:39
반응형

System.InvalidOperationException : 임시 클래스를 생성 할 수 없습니다 (result = 1).


.net 3.5를 사용하여 응용 프로그램을 개발했으며 동일한 환경의 여러 컴퓨터에 .exe로 배포했습니다. 그러나 한 특정 컴퓨터에서 다음 오류가 발생합니다. 스택 추적 :


이 대화 상자 대신 JIT (Just-In-Time) 디버깅 호출에 대한 자세한 내용은이 메시지의 끝을 참조하십시오.

System.InvalidOperationException: Unable to generate a temporary class (result=1).
error CS2001: Source file 'C:\WINDOWS\TEMP\wz58eig4.0.cs' could not be found
error CS2008: No inputs specified

   at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
   at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
   at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
   at System.Xml.Serialization.XmlSerializer.GetSerializersFromCache(XmlMapping[] mappings, Type type)
   at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
   at System.Web.Services.Protocols.SoapClientType..ctor(Type type)
   at System.Web.Services.Protocols.SoapHttpClientProtocol..ctor()
   at SSOClient..ctor()
   at sc.tradesvc.SSOManager..ctor()
   at sc.tradesvc.SSOManager.get_Inst()
   at sc.cashflowgenerator.Controls.LoginForm.btnLogin_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.PerformClick()
   at System.Windows.Forms.Form.ProcessDialogKey(Keys keyData)
   at System.Windows.Forms.TextBoxBase.ProcessDialogKey(Keys keyData)
   at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
   at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg)
   at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)

로드 된 어셈블리 :

mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll

CashflowGenerator
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/DATA/DEVEL/Output/CashflowGenerator.exe

System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll

System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll

System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll

System.Core
    Assembly Version: 3.5.0.0
    Win32 Version: 3.5.21022.8 built by: RTM
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll

System.Web.Services
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Web.Services/2.0.0.0__b03f5f7f11d50a3a/System.Web.Services.dll

************** JIT 디버깅 ************** JIT (Just-In-Time) 디버깅을 사용하려면이 응용 프로그램에 대한 .config 파일 또는 컴퓨터 (machine.config)에는 system.windows.forms 섹션에 설정된 jitDebugging 값이 있어야합니다. 또한 응용 프로그램은 디버깅이 활성화 된 상태로 컴파일되어야합니다.

예를 들면 :

When JIT debugging is enabled, any unhandled exception will be sent to the JIT debugger registered on the computer rather than be handled by this dialog box.


Could someone help me with this?

As I am new to .net could someone also tell me when why a temporary class needs to be created in the first place?


XML Serialisation works by generating code to perform the serialisation. This is done in a temporary assembly created for that purpose the first time it is needed.

However this relies on being able to write the assembly to disk.1

Your options are either to (1) given the user account which is running the process write permission (for an ASP.NET application this is likely to be a bad idea). (2) Use the SDK tool (sgen.exe) to pre-generate (at development/compile time) the serialisation assembly, and then use (and deplot) that assembly.

1Open question: the APIs exist to create assemblies dynamically in memory: why not do that?


I just spent a lot of time searching for the answer to this so I thought I'd add it here to save some headache for others. If you use the xsd.exe tool to generate your cs it may have added double arrays [][] where an array should be []. Replace all [][] with [] in your generated cs file and retry.


You only have to give the List Folder Contents and Read permissions on %windir%\Temp.

I found this post when trying to fix my problem, and didn't have to give my user account write access.

From Microsoft


You Need to give the permission to the temp folder which is in windows folder. And Your Problem is Solved...........


Surfacing @grzenio's comment a bit further for recent users:

If you go to Project Properties -> Build -> Generate serialization assembly -> On, it forces the generation of the XML serializers assembly at compile time, eliminating the need to do so at runtime.

In turn, this means you don't need to change filesystem permissions (useful if you're, for example, hosting on Windows Azure Web Sites, where that isn't an option).


You need to add *IIS_IUSR* user with read write permission to C:\Windows\Temp folder.

NOTE: Everyone user will not work with full control.


It may be also just some simple error in the serialized class (typically a result of some copy/paste). For example the following class will cause this error:

  public class Foo
  {
      private string[] contexts;

      /// <remarks/>
      [System.Xml.Serialization.XmlArrayItemAttribute("Context", 
       typeof(Property), IsNullable = false)]
      public string[] Contexts
      {
          get { return this.contexts; }
          set { this.contexts = value; }
      }
  }

Notice that typeof(Property) parameter in XmlArrayItem attribute is not compatible (most likely) with string causing similar exception:

System.InvalidOperationException: 
Unable to generate a temporary class (result=1).

If typeof(Property) is replaced with typeof(string) serialization will work again.


the APIs exist to create assemblies dynamically in memory: why not do that?

Just a wild guess: I assume this possibility did not exist yet in .NET 1.0, or at least when the XmlSerializer was created and MS doesn't like changing existing behavior...


Give Read/Write Privileges to 'C:\WINDOWS\TEMP' folder. It will work.


It may be bacause you are switching application pooling identity in IIS to be password instead of predefined so you have one off the following

  1. return to predefined
  2. give prmission full control to user IWAM_WBSRV-01 on the windows temp folder

In case this helps anyone, my problem was coming from an inherited class used in the serialization. The problem went away when I made a full copy/paste of my class I was serializing and quit using ineritance. Unfortunately, the advantages of inheritance went away, but that is better than having this problem. (Hey, at least I'm pretty sure that's what solved it. Happened to do a reboot in there somehwere too.)

참고URL : https://stackoverflow.com/questions/657993/system-invalidoperationexception-unable-to-generate-a-temporary-class-result-1

반응형