Log4NET setting overwritten by AssemblyInfo Task - msbuild

I have a project that uses log4net and works fine on the developer machines. When we build, a step in our build scripts calls the AssemblyInfo task to set version numbers and dates, etc. But the AssemblyInfo file also loses the line:
[assembly: XmlConfigurator(Watch = true)]
Is there any way to have the AssemblyInfo task not overwrite that line, or conversely, to have the AssemblyInfo task re-insert that line into the file (along with the appropriate using statement?

You can actually put the log4net [assembly: ...] line in any file that will be compiled into the assembly. A lot of times, we just put it in the .cs file that has the "main" method, and it works just fine.

Well, thinking a little differently, you don't have to have only one assembly info file.
This is how we do it for a solution, each project has 3 assembly info files:
AssemblyInfo.cs - Contains Guid, AssemblyTitle, AssemblyDescription, and any assembly specific attributes.
ProductAssemblyInfo.cs - Contains AssemblyProduct, AssemblyVersion and AssemblyFileVersion. This way all assemblies in a product/solution share the same version.
CompanyAssemblyInfo.cs - Contains AssemblyCompany, AssemblyCopyright, and any attributes we want all our assemblies to share.
Items 2 and 3 are referenced using "Add as link", this way they are shared from the single source code. Now, you may not want to adopt the same approach, but you could certainly use a similar structure and place your XmlConfigurator in a separate assembly info file from your assembly version details.

Related

Rename class in external dll without losing reference to it in unityEditor

We've got a visualstudio solution with all our code in it and it's completely seperated from our unity project.
When we build our code into a dll from within visualstudio, the dll is copied over to the unity project plugins folder, so we can use the classes from it in our unity project.
This all works fine, but the problem is when we rename a class in our visual studio solution, rebuild the dll and go back to the unity project, the reference to the renamed class is lost in our scene and/or prefabs...
I looked into the scene & prefab files and noticed the references to the classes in the dll are defined as follows:
m_Script: {fileID: 698634159, guid: aa20b9c3579870b40bb96d13672546a3, type: 3}
I read on the forums that the fileID is generated based on the namespace & name of the class file, so logically when the class is renamed, this fileID changes and unity does not know it needs to reference the renamed class.
Is there a way to define a hard references of some kind, so the reference does not get lost when renaming a class? Or any other suggestions to keep references from getting lost.
I've also tried including a meta file with a guid in the dll, but unity does not seem to take this meta file into account, as it always uses the guid of the dll together with the generated fileId.
Unity can't automagickaly find out you have renamed some class inside the DLL. That's true for any form of project : if you depend on some DLL, and classes changes in the DLL, there is no indication of rename.
The best way to link them is adding your Unity project in the solution, and place a dependance between Unity project and the another. Then maybe the refactor tool will suggest you the rename in the Unity project.
Here is a really good tool to find and replace missing scripts, which i assume is the error you are getting.
http://daikonforge.com/forums/resources/fix-missing-scripts.3/
It comes with the source code once you unpack the Unity3d Package, so you can customize it to your needs.

Accessing embedded resources in Wix DTF Custom Action

My DTF project contains some embedded resources and I would like to access the same in the CustomAction.
I tried the following code in the Custom Action method
// Gets the current assembly.
Assembly Asm = Assembly.GetExecutingAssembly();
// Resources are named using a fully qualified name.
Stream strm = Asm.GetManifestResourceStream(Asm.GetName().Name + "." + Name);
However this doesnt work as Asm always refers to the Wix Setup assembly and not the custom action dll which contains the resources
Why not use Assembly.GetAssembly(typeof(CustomAction));, to get the assembly that contains your custom action?
To be honest, I'm not sure this scenario is possible. I mean, there might be no option (or no easy option) to get the custom action executing assembly and extract the resources out of it.
Instead of this, I would try to re-design the solution and move resources to the Binary table in MSI package. Thus, you'll still have embedded resources, but not in CA DLL, but in the MSI package itself. The DTF.chm help file contains a sample how to extract files from Binary table - it's a matter of a couple of lines of code.

MVC - Application Assembly

Question:
If I have multiple projects in one solution is it still considered a single assembly?
Background Information:
I'm aware the 'MyApplication/Properties/AssemblyInfo.cs' file exists. Further, I confirmed that when I:
Add a project to the solution.
Appropriately reference the newly added project.
Lastly, Build the solution.
The 'MyApplication/Properties/AssemblyInfo.cs' file has not changed. This leaves me to believe, and please correct me if I'm wrong that I'll have met the demand.
Thank you
No.
Each project is compiled into one assembly in your case. The assemblyinfo.cs file (for each project) should not change at all when you compile anything. Also, that file's name is not important at all; it's the global attributes inside it that cause various properties of the assembly being created to be set. That file's name and location are simply a convention.

Assembly referenced in SSIS 2008 script task not working correctly

I have reference a custom assembly in an ssis script task. The script task apparently works correctly but the assembly (first tested with a console program) doesn't work anymore.
The assembly is supposed to transform a text file to a csv file for further import. Once loaded in the script task the function referenced does create an empty file. Logging did not bring any addtionnal info.
Currently the assembly is strongly named, signed, in the GAC as well as in the DTS\SDK folder of MSSQL server.
Any idea ?
Actually the error was in my own assembly. So to summarize the correct and easy way to include and use an assembly file in a ssis script task is :
Compile the assembly with the correct framework version (in my case 3.5)
Sign the assembly
Put the assembly in the GAC
Reference the assembly within the script task and add an "imports" directive
Actually putting the assembly in the DTS\bin folder did not produce any difference.
This is why I don't usually like using custom assemblies in SSIS. In this case, I would write a jig (exe) to call the assembly and change SSIS to call my exe. In the jig (exe) I would wrap the call to the assembly in a try/catch block. I would trace the incoming parameters and log any errors to a text file or to the system Event Log. Usually, this approach gives me enough insight into the real problem (bad param, permission problem, weird data, etc) and a good way to recreate the problem and verify a solution.

merge DLLs n .cs files

A part of big project is a payment system, that I would like to reuse. I want to merge all the class files of this payment system into DLLs so that add them as a reference in all the other projects. The present payment system is also using namespaces from the DLLs of a commercial application (nsoftware-paypal n few others). I tried csc to compile the individual files into DLLs but couldnt make it work. I also tried the ILMerge but this doesnt seem to work either.
CSC
As the .cs files uses the namespaces from the DLLs of nsoftware-Paypal, I included DLL files along with .cs in csc command. it gives me an error saying "...nsoftware.InPayPal.dll is a binary file instead of a text file". When I try to compile without the paypal DLLs it throws an error saying 'The type or namespace named nsoftware is missing'.
ILMerge does not allow the .cs files either(as its not an assembly of course).
All I need to do is to generate the one(or more) DLLs for this whole system so that I can use it in other projects.
Possible?
you need to compile your .cs files using csc, then use ILMerge to combine the 3rd party assemblies with your generated assembly.
fyi there is an open source gui for ILMerge that can make things a little easier (at least at first).
http://sourceforge.net/projects/gilma/
In regards to your compilation issues you might want to check out this tutorial
in order to compile your code with a dll do something like this
csc /out:out.exe /r:third_party_dll.dll program.cs
You need to use dllImport:
Take a look at this Example-Code:
http://www.adp-gmbh.ch/csharp/call_dll.html
Or this example:
http://www.codeguru.com/csharp/csharp/cs_data/article.php/c4217
If you need to pass structures:
http://msdn.microsoft.com/en-us/library/awbckfbz.aspx
And finaly the documentation for dllImport:
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx