Every time I update a file in the APP_CODE folder in asp.net I get the following error.
System.InvalidCastException: [A]TexasClass.TexasTest cannot be cast to [B]TexasClass.TexasTest. Type A originates from 'App_Code.w8xmcutn, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\15ae04a3\80f6a04b\App_Code.w8xmcutn.dll'. Type B originates from 'App_Code.dqtbd99q, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\15ae04a3\80f6a04b\App_Code.dqtbd99q.dll'. at ASP.admin_texesview_aspx.OpenExam(Byte[] bin)
The problem is a duplicate DLL is created when I update a code file. I can resolve it by restarting the server(I did that because I am not sure which file to delete).
Why is this happening and how can I avoid it?