I have attached the sample in the following location
https://onedrive.live.com/redir?resid=D3615D07F8A53977!3971&authkey=!AJ1EjQrQbnDA9sw&ithint=file%2czip
And I have the following problems in the above sample.
When changing IEnumerable to IQueryable using AsQuerable method, the MissingRuntimeArtifactException is thrown. This problem has been solved when using the below line in rd.xml file in App1
<Namespace Name="System.Linq" Dynamic ="Required All" Serialize="Required All" XmlSerializer="Required All" />
My question is how to include rd.xml file in CustomButton class library? If I add manually by adding new xml file in CustomButton, its not working when I run App1 with CustomButton dll. How to resolve this?
While using Expressions in IQueryable extension method(Count()) the same exception has been thrown. Please suggest any solution for this issue.
Regards,
Antony Raj
If you use the template for Class Library (Universal Windows) it will do two things that you'll find beneficial.
It will generate a .rd.xml template
At build time, it will embed this xml file into your library as a resource
When compiling applications to Native code the .Net Native toolss (ilc.exe) will look for all files in the project that match *.rd.xml and all resources in libraries. Embedding this way makes deployment of your library much simpler.
If you'd prefer to not embed this asset it'll be up to you to make sure the file lives next to your assembly via whatever deployment mechanism you prefer. (Sometimes it's included in Nuget package and just copied around.)
Also, I'd highly advise against using the directive you have above. In particular the portions of it that are Serialize="Required All" and XmlSerialize="Required All". Adding those to the directive will great bloat the amount of serialization code generated and it's pretty unlikely you actually need to XmlSerialize ALL of the types in System.Linq.
Related
At the moment of creating a project of type "Library of Classes, usually one can generate a dll when compiling, but how could I generate a dll without losing others that I already have included?
I explain with an example: It turns out that Nuget downloaded an S22.Imap dll with the one I worked with, later I generated the dll in the traditional way that I explained in the beginning, but when I wanted to work with dll in another computer, I got errors that were not I found functions that contained the S22.IMAP dll. So to solve this problem, I had to copy the dll of my project, S22.IMAP in an additional way in a specific path of the other computer.
My question is:
How could you generate a dll that includes the ones included in the project you were working with?
All the referred 3rd party dlls (S22.Imap.dll in your example) will be copied to the output folder together with your own dll file (let's say a.dll) when you build your project. That means you should always copy them together (S22 + a.dll) to the place you want to refer them, on another computer/folder/place.
If you really want to make them only one file (although it is not recommended), you can set the S22 one as some "nested resource". Then you will get only one a.dll file and the S22 one is inside the a.dll. See below page for some reference:
Embedding one dll inside another as an embedded resource and then calling it from my code
AND, ILMerge is some tool that can help you do so.
In general, you don't. A DLL is a dynamic linked library, and you would normally only combine static libraries during a build. Here is an answer on the difference between static and dynamic linking.
Typically you would include all the DLLs you need in the installer package. If you use Visual Studio to create the installer, it can detect the dependencies for you. When you run the installer, all of the necessary DLLs are deployed. Nearly all commercial .NET software follows this pattern.
It is possible to merge an assembly into another assembly using a tool called ILMerge. This would be a very unusual thing to do, and could cause issues with intellectual property and code signing, so it is not recommended.
I'm working on a project where we are compiling, emitting and running code using Roslyn. I've run into an issue where Roslyn does not embed resource files in the DLLs I emit using Compilation.Emit().
I see there is an argument of type IEnumerable<ResourceDescription> which I think I need to use.
Unfortunately, I can't find any information on resources in Project, so I'm not sure how to get the information I need.
Does Roslyn allow users to uncover any information about resource files? Or will I need to fall back to EnvDTE or using MSBuild manually? (If I need to use MSBuild, how do I support DNX projects?)
It looks like this information bypasses the project system, and is instead passed directly from the MSBuild loader to the command line arguments.
Source
Basically, I developped a small library with some common fonctionnalities that I use in all my projects. For some political reasons, I cannot choose a generic name for that library (including namespace and assembly name). Usually, it must include the name of the enterprise, something like this for the namespace: Enterprise.ProjectName.XXX.YYY.
For the moment, I'm doing a copy of my library, then I'm renaming the namespaces manually with Visual Studio, and finally I'm recompiling the whole thing.
So my question is the following: Is it possible to create a small program that takes an assembly as input, rename all namespaces from MyLibrary.XXX.YYY to Enterprise.ProjectName.XXX.YYY as well as the assembly name?
What are the steps to follow?
[Edit]
Generating the assembly automatically seems to much work. I will use resharper and/or CTRL+ALT+F like I did so far. Thanks for the answers...
You could use Mono's Cecil project to disassemble the assembly, inspect each type, rename or recreate the type with a new namespace, and generate the resulting assembly.
That being said, it might be simpler to use a tool like Resharper which allows you to rename namespaces correctly within the code base.
Some options:
If you are copying the entire source code for your library into your new project, you can use a refactoring tool like Resharper to "Adjust Namespaces". This is a pretty quick and safe refactoring.
If you just need to avoid shipping the internally named assembly, you may be able to use ILMerge to 'hide' the internal assembly during a post-build step. This is viable if it's just a perception issue for the final assembly names in the binary output directory.
Deal with the issue at the political level by describing your internal library as being no different from any other third-party dependency. Then the naming is no longer a problem. This may solve other problems if you're shipping the source code of this library to multiple clients, as it clarifies that you are not giving full ownership of your 'shared' code to each client. Otherwise they could potentially argue that you are not allowed to use that 'shared' code in projects for other clients, since it is clearly owned by them, having their enterprise name in the namespace.
I want to extract custom attributes from source code from different .CS files. I have list of files .
Scenario is that i have Project A which reads files of Project B. It has to extract all attributes used in Project B.
My question is that how can i do that without using Reflection.
Reflection deals with assemblies but i have source code.
Using Roslyn would be over kill?
what approaches are there?
I had another option to Compile using MSBuild but for large scale projects it would not be feasable due to heavy dependencies. and it seems not a good way to build application and then going for its assemblies
i just want to have some sort of thing that tells me what attribute was on what class and possible a UML diagram of relations of that classes.
Please give your suggestions
You could use NRefactory: https://github.com/icsharpcode/nrefactory (also available as a NuGet package)
(VS 2008)
I'm using a C# library for my VB.NET project. And the method summary/notes or what they are called do not show in intellisense. Is this supposed to be like that? Or is there something I must do to fix it? And if not, will VS 2010 be able to do this?
EDIT: Still unresolved. Now building library dll + xml file, but how to import the xml file in my vb project?
See image: http://i52.tinypic.com/25kh5xw.png
In C# library, go to the properties on the build tab, and check the checkbox for including XML documentation and specify the name and path. After that include the new library in your VB.Net project.
one reason could be resolved by importing the namespace needed
another reason could be due to faulty writing
if you send the code where the problem is we might be able to help you
If you're using source control (TFS or Github) then you need to the following:
Check in ( Push) for safe return point (base line)
Delete the references from the project.
Delete the custom dll's from the solution.
At this point the libs are marked as [removed], if you would add them again at this point, they will just be marked as [changed] again. This did not include the summaries for me.
Check in (push). dll's are now removed from source control as well.
Drag and drop the dll's (including xml) into the solution (I recommend using this method for including dll's
Add references to these dll's via Browse.
Check if you have summaries.
Check in (push).