WCF service in precompiled web application - Failed to load file or assembly

I have a solution that contains several WAPs (web application projects).
Each WAP has its own Web Deploy project to be able to precompile these sites. In one of the web applications, we created a new WCF file with

AspNetCompatibilityRequirementsMode.Allowed 

In debug mode, it works fine, but if I switch to release, it will work:
(we use msbuild to create deployable versions)

Could not load file or assembly 'App_Web _ *****, Version = 0.0.0.0, Culture = neutral, PublicKeyToken = null or one of its dependencies. The system cannot find the specified file.

I found some explanation in this link: WCF service

WCF stores the list of reference assemblers in the customString attribute as a result of the assembly (service.svc.cdcab7d2.compiled), including App_Global. There seems to be a false assumption that these collections will always be there, which is not necessarily the case in web deployment projects (aspnet_merge), where the collections will be combined. After the merge step of the assembly, in fact, everyone united into a single assembly (say, MyWebSite.dll), since we selected this option in WDP. ASP.NET only updates the .compiled files he knows, so App_Global.asax.compiled really has the correct link to MyWebSite_Deploy.dll instead of App_Global.dll. The original assembly is deleted after the merge step. WCF reads a list of previously saved assemblies, and throws when it cannot find App_Global

List of solutions I tried:

1.Check "Allow updating this precompiled site" - does not work

2. Manually delete the App_ * link from the service.compile file
(It worked, but it should be a different solution)

3.Add the full name of the / factory service in .svc
The service has a full name.

4. Let's try to install this key:
<SourceWebPhysicalPath>..\..\ProjectName</SourceWebPhysicalPath>

after these instructions

5. <compilation debug="false" batch="false">

Tried this to install in web.config using these instructions

6. "Merge all outputs into one assembly"
I have not tried this because it requires registering all used assemblies in the GAC and means that we need to change the deployment logic.

I do not want to delete the asp.net temporary folder because it stops the application and this is unacceptable

I also found Scott Guttree's link , but with '07 he had to make a path to asp.net 4.0

Additional Information

Service posted:
ProjectName\WebResorce\Service.svc ,

 <%@ ServiceHost ... Factory="SolutionName.SharedWeb.WadoLabsServiceHostFactory" %> 

where SharedWeb is a collaborative web project



Do you have any other ideas?
thanks in advance

+1
source share
2 answers

The following setting worked for me:

  • In the svc file, specify the qualified service name as <%@ ServiceHost ... Service="<Namespace>.<ServiceContractClass>, <AssemblyName>" CodeBehind="ServiceContractClass.svc.vb" %>
  • (I can't remember why this was necessary, but) I made sure that the namespace and AssemblyName are different.

The trick is to specify a qualified name, including AsseblyName. (The assembly name specified in the project that contains the service, and not in the Web Deploy Project).

Also note that there is a space between the comma after the class name and AssemblyName.

+1
source

Why don't you implement WCF services in a separate library project inside the same solution and just reference this project from your web application? Thus, they will remain outside the pre-compilation process, and you can work with predictable type names inside * .svc files. In addition, it will probably also give you a cleaner solution structure.

+1
source

Source: https://habr.com/ru/post/1436111/


All Articles