Can't load a compiled dll first time

Discussion in 'ASP .Net Web Services' started by iunkwn, Apr 4, 2012.

  1. iunkwn

    iunkwn

    Joined:
    Apr 4, 2012
    Messages:
    1
    Likes Received:
    0
    Hello Gurus, I have a WCF service that exposes a method. When a client calls this method, the following occurs:
    1) the method does some processing
    2) it tries to load an assembly if its already there
    3) if the above dll isn't there, it generates C# code, compiles it using CSharpCodeProvider's CompileAssemblyFromSource api
    4) It then loads the just generated assembly

    Now the problem. The first time the method it called, it generates the assembly at point 3), and when it tries to return the assembly reference via CompilerResults.CompiledAssembly it throws a file not found exception. However, I can clearly see that the assembly has been generated at the specified location and I can open it with other applications.

    If I call the method again via a client, it is able to load the assembly (it was successfully generated as a result of the previous call) and goes ahead to do the remaining set of tasks. Only when the assembly isnt there and it generates it and goes ahead to load it immediately, I get that exception. Any ideas? I have tried playing around with the web.config, changing impersonation to true/false. I have a seperate app pool to run this web application and I tried changing the identity of the app pool from local service to local system, even gave my windows logon credentials which has admin rights but no luck.

    Any help would be much appreciated.
     
    iunkwn, Apr 4, 2012
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.