WCF, how stop stop log4net file being created on build - wcf

I am having a problem with the log4net file in a WCF service i have created.
When i build and run my WCF services it created log4net then errors with the following...
"Could not load file or assembly 'log4net' or one of its dependencies. An attempt was made to load a program with an incorrect format."
When I delete the fle from the bin folder and refresh the browser the services run fine.
So, how can i stop the log4net being created in the bin foler when i build my project? as i dont need it

Somewhere in your service project, you probably have a reference to a log4net assemly. Or the log4net assembly is referenced in another assemly that is referenced in your service project. Somehow it is chained-in as a dependency for your service to be deployed and is therefore copied into your bin folder.
Find the reference to the log4net assembly, select it and select Properties from its context menu. In the Properties window set Copy Local to false. This will prevent the assembly to be copied into the output bin folder.

Related

Reference VB.NET DLL in Kofax Document Validation Script

We are working on a validation script for Kofax Capture 9.0 / 10.0 in VB.NET 3.5.
We know how to create a script using the Admin Module, and how to get it operational.
The problem is that we need to reference a dll, located on a remote machine. (GAC is no option) This dll holds abstract classes we need in each validation script.
Even when putting the dlls locally (copy local), the Validation Module (index.exe) immediately throws the "cannot find reference" exception, even though the project compiled perfectly.
I guess the basic question comes down to: where do we put the dlls, in order for the Validation Module to find them?
The simple answer is to put the dll in the same folder as the application because this is one of the places which .NET will probe when trying to find it. The Validation module is run from the Capture bin directory which will be something like "C:\Program Files (x86)\Kofax\CaptureSS\ServLib\Bin\". This would need to be done on each client using Validation.
If you have a more complicated scenario, you could look implementing the AppDomain.AssemblyResolve Event and using Assembly.LoadFile to get the assembly from a custom location, but the using the bin path is less complicated.
If you end up having further trouble, you can troubleshoot by using the Assembly Binding Log Viewer (Fuslogvw.exe) which can tell you more details about why the assembly failed to load and where .NET tried to search for it. Assembly loading can fail for reasons other than just the path.
For more detail on how .NET loads assemblies, see the following:
How the Runtime Locates Assemblies
Locating the Assembly through Codebases or Probing
We found a solution: add all library files as "links" to the project. (Add --> Existing File --> small arrow next to "Add" --> Add as Link)
This ensures the files are compiled when you build the project. The Kofax Validation Module can now find the files, whereas when referencing the file, it could not. Why it could not, remains a mystery...

NUnit unable to load dll with String Key Name

I have a project in which I have some C# classes which I am building using csc in my ant script. I have also have written some unit tests which I want to test with NUnit2.6, My test class and actual class refer to one DLL which is compiled with String Key Name (.snk), if I install thi DLL in my GAC (gacutil /i myDLL.dll) everything works fine. As soon as I uninstall this DLL from my gac I get following error for all the test during the build when I try to run my test using NUnit;
Test Error : fromJDynTest1
[exec] System.IO.FileNotFoundException : Could not load file or assembly 'myDLL, Version=5.1.0.0, Culture=neutral, PublicKeyToken=c0409b584f86b2d6' or one of its dependencies. The system cannot find the file specified.
[exec] at fromJDynTest1()
...
...
Does anyone know how to resolve this. Let me know if you need any other information.
Thanks
--
SJunejo
The code you are testing cannot see the assembly in question when you place it in the gac it can see the assembly. You need to ensure that the code you are testing has the assembly in the bin directory when compiled (perhaps copy local is set to false in your project on the assembly reference).
The reason I am sure it is not a dependency (which is mentioned in the message) is because the situation is resolved when the assembly is placed in the gac. This error is not likely caused because the assembly is strongly named.
Failing that the test code refers to the assembly and that test code either doesn't have a reference or has the same problem (not in its compiled directory).
Would help if you posted the actual test or structure of the project.
.net locates assemblies as follows:
Determines the correct assembly version by examining applicable configuration files, including the application configuration file, publisher policy file, and machine configuration file. If the configuration file is located on a remote machine, the runtime must locate and download the application configuration file first.
Checks whether the assembly name has been bound to before and, if so, uses the previously loaded assembly. If it failed before it will fail again now.
Checks the gac. If the assembly is found there, the runtime uses this assembly.
Probes for the assembly (if you open up a .csproj file in a text editor you will see hintpaths, which try and help .net find the assembly).

Unable to load type NHibernate.ByteCode.Castle.ProxyFactoryFactory

As I read and try every topic similar without success, I decided to post my own question. My solution has a console app and a class library for dataaccess. The Nhibernate configuration is inside the appconfig in the console app (which I'm currently using for debug, as I will after make a Web App and migrate all configuration to web.config).
The exception is well know:
NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException: Unable to load type NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle.dll' during configuration of proxy factory class. Possible causes are: - The NHibernate.Bytecode provider assembly was not deployed. - The typeName used to initialize the 'proxyfactory.factory_class' property of the session-factory section is not well formed. Solution: Confirm that your deployment folder contains one of the following assemblies: NHibernate.ByteCode.LinFu.dll NHibernate.ByteCode.Castle.dll ---> System.IO.FileNotFoundException: Could not load file or assembly 'NHibernate.ByteCode.Castle.dll' or one of its dependencies. The system cannot find the file specified.
The steps I took to try to solve it:
1) The dll in the deployment folder - I have the following dll in my bin:
Castle.Core.dll - v. 2.5.1
Iesi.Collections.dll - v.2.0.0.1002
log4net.dll - v. 1.2.10.0
NHibernate.ByteCode.Castle.dll - v.3.0.0.2001
NHibernate.dll - v.3.1.0.4000
2) The configuration contains
name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode
3) I set my MetaManager.Data project to deploy in a x86 CPU
4) All dll in my bin folder are referenced in the project.
I think this it it. I do not know were else to go :(
To find out which dlls are loaded or rejected by which component you can use the "Assembly Binding Log Viewer" (Fuslogvw.exe) that belongs to the dotnetsdk . If logging is enabled it can show you wich assemblies are loaded and which assembly caused it to load.
For details see http://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.80).aspx
I think the version of the Iesi.Collections and NHibernate.ByteCode.Castle assemblies should be the same as for the NHibnernate assembly, i.e. 3.1.0.4000 (at least that's the version of the assemblies distributed with NH 3.1.0 GA).

Deploying WCF Services

I have a WCF visual studio project, which contains many SVC files.
Can I compile each SVC file into its own dll file?
my target is to be able to deploy each svc file separately without touching other services, but maybe keep them on the same website
what options I have?
No, you cannot compile the svc files.
You can however compile your actual service code into an assembly (if you haven't stuck it into YourFile.svc.cs codebehind file), and then deploy that compiled assembly into the bin directory below the virtual directory where you svc files exist.
If you want to have an assembly for each service, you will need to create a class library project for each service, put the service implementation inside that, compile it, and then deploy that resulting assembly into the bin directory.
The svc files must be deployed as is, and they must be copied into a virtual directory (or a subdirectory thereof) in IIS.

WCF The service '/myservice.svc' activated due to an exception during compilation

Our current deployment strategy is to deploy all assemblies with each application / service but control where *.exe and service implementaion assemblies are deployed. With that in mind, I have a specific service that when I deploy 2 unreferenced resource assemblies I get a compilation error. System.IO.FileNotFoundException: Could not load file or assembly '****.resources, Version=1.0.1262.0, Culture=fr, PublicKeyToken=null' or one of its dependencies
I do not have the sub folders for each language deployed in the bin folder e,g, "fr" etc.
Can somebody tell me why these "unreferenced" assemblies are causing compilation errors?
Most of the time this kind of error can be attributed to a View referencing a resource by a resource key. This would cause an ASP.NET compile time error.
You can check to see what the requesting DLL is by using fuslogvw.exe to figure out what the binding error is. If it's a DLL with an obscure name like ASP.jwnca.dll this is probably the case.
Why not just deploy these files?
Hope this helps.