Where does the Xml Serializer store its dynamically generated code? - xml-serialization

The XML serializer in System.Xml.Serialization namespace generates the XmlSerializationReader and XmlSerializationWriter classes dynamically using CodeDOM.
I want to have a look at these classes in the disassembler.
Where does the serializer store the temporary assembly file that has this dynamically generated code? I have been trying to find it out for the last 30 minutes in Reflector but to no avail.
All I gather from Reflector is that it stores it in some temp directory. I looked up C:\temp but there's no .dll there. I looked up C:\tmp and there are some PNG files there that seem like they are not really PNG's but some binary files generated by Windows for storing temporary data.
If you know, please tell me.

Alright, these two threads out of the dozen or so pertaining to this issue that I looked up reveal the answer.
This thread says it is the folder C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp
http://snavin.wordpress.com/2013/04/01/xmlserializer-is-running-does-not-have-sufficient-permission-to-access-the-temp-directory/
But from the stack trace posted in the original question on this thread, it appears that the temp folder of the windows environment, which can be found out by calling System.IO.Path.GetTempPath() is where the dll is saved.
ASP.NET Access to the temp directory is denied

There is an easy way: use sgen.exe to generate necessary assembly by yourself.
On my machine it looks like:
C:>"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\sgen.exe" "C:\Projects\BIN\My.dll"
Microsoft (R) Xml Serialization support utility
[Microsoft (R) .NET Framework, Version 4.6.1055.0]
Copyright (C) Microsoft Corporation. All rights reserved.
Serialization Assembly Name: My.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
Generated serialization assembly for assembly c:\projects\bin\My.dll --> 'c:\projects\bin\My.XmlSerializers.dll'.

Related

Metadata file not found - Data.Entity.Model

Anyone having similar problem, while creating webservices?
Compiling transformation: Metadata file 'D:\Program
Files\VS2013\Common7\Tools..\IDE\Microsoft.Data.Entity.Design.dll'
could not be found D:\PROJEKTY\apki\ws2\WS\WS\DataModel.tt
I tried adding data model again, restarting VS, cleaning and building solution, creating new project, deleting and adding reference, installing the newest version. I think that any solution found on internet does not work for me.
Any suggestions? I think of pasting file into this directory, but can't think what may be there.
Based on
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF6.Utility.CS.ttinclude
, the code generator is looking for the missing DLLs in the following locations:
<## assembly name="%VS120COMNTOOLS%..\IDE\EntityFramework.dll" #>
<## assembly name="%VS120COMNTOOLS%..\IDE\Microsoft.Data.Entity.Design.dll" #>
I discovered that the environment variable %VS120COMNTOOLS% is not compatible with the correct installation path of visual studio, so I changed it from Advanced system properties and it worked
Check your install location. I installed VS to the other location D:\ than default C:\ so I got the error.
modify "Environment Variables" to your location, for me it means changing C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\ to D:\Microsoft Visual Studio 12.0\Common7\Tools\.
DON'T Forget to add a \ to the end of word.
I believe VS is not updating the VS120COMNTOOLS variable correctly when reinstalling VS to a different drive. See this SO thread for an extended answer.
The problem lies in the fact that the file originally EF6.Utility.CS.ttinclude wrong. Even if the variable %VS120COMNTOOLS% is the correct value, the error still occurs.
Blame the two stupid points in the following lines (%VS120COMNTOOLS%..\IDE):
<## assembly name="%VS120COMNTOOLS%..\IDE\EntityFramework.dll" #>
<## assembly name="%VS120COMNTOOLS%..\IDE\Microsoft.Data.Entity.Design.dll" #>
If that's the way to fix the error no longer occurs:
<## assembly name="%VS120COMNTOOLS%\IDE\EntityFramework.dll" #>
<## assembly name="%VS120COMNTOOLS%\IDE\Microsoft.Data.Entity.Design.dll" #>
And the variable %VS120COMNTOOLS% must have the correct value, of course.
The question is old, but the answer is still relevant now, because this error persists, and in the VS2015. Below lines from the ill-fated file:
<## assembly name="%VS140COMNTOOLS%..\IDE\EntityFramework.dll" #>
<## assembly name="%VS140COMNTOOLS%..\IDE\Microsoft.Data.Entity.Design.dll" #>
Sorry.
Not sure why this is happening. One of my colleague faced this issue when he is trying to generate database from Model in a common server that we are using. I tried in the same machine with my login from my PC and it worked for first time and i tried again and i got the same error. I just did a
devenv /resetsetting
in VS 2013 command prompt and it worked. Did the same in my colleagues machine and it worked too. Not sure it will workbut wort a try
This worked for me.
Go to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF6.Utility.CS.ttinclude
Edit it with Visual Studio.
Remove the two dots after the URL, so the new lines like:
<## assembly name="%VS120COMNTOOLS%\IDE\EntityFramework.dll" #>
<## assembly name="%VS120COMNTOOLS%\IDE\Microsoft.Data.Entity.Design.dll" #>
Fix your environment variables to end with directory just befor IDE. In my case
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\
Rebuild the project or delete the entity framework and recreate it.
Good day guys, Ive encountered this error in the app im working on what I did was:
1. revert the solution/module where the entities,
2. Remove the %VS110COMN%
so the code will look like this
<## assembly name="..\IDE\EntityFramework.dll" #>
<## assembly name="..\IDE\Microsoft.Data.Entity.Design.dll" #>
I know this is late to respond to the question but.
This work For me by following the below steps.
Copy the code form the existing abc.tt file.
Delete the abc.tt file.
Copy all the code again into ABC.tt file.
After copy code just save the file and build the solution it will regenerate the complete .cs file as well.
Try this:
Double Click on the .edmx Model
Right click anywhere on the "Entity Data Model Designer"
Click "Update Model from Database"
Click Finish

Determine difference between COM and .NET DLLs in Powershell

I'm writing a script to copy and move DLLs from the bin folder to a mapped drive, and I need to register/unregister the DLLs during the process. I've figured out how to do all of this, but there's a catch. The program I'm working on utilizes VB6 COM DLLs and VB.NET .NET DLLs. I understand that COM DLLs use regsvr32.exe, and .NET DLLs use regasm.exe, but I am interested in programmatically calling the correct function, based upon the DLL I am moving. Is there a way to determine what time I am using in Powershell?
Call
[Reflection.Assembly]::LoadFile( `mydll.dll`)
It should raise a BadImageFormatException if it is not a .Net dll.
As per MSDN:
"This exception is thrown when the file format of a dynamic link library (.dll file) or an executable (.exe file) does not conform to the format that is expected by the common language runtime. In particular, the exception is thrown under the following conditions:
...
An attempt is made to load an unmanaged dynamic link library or executable (such as a Windows system DLL) as if it were a .NET Framework assembly. The following example illustrates this by using the Assembly.LoadFile method to load Kernel32.dll."

WCF: SvcUtil.exe with imports issue

One of the requirement in our project is as follows:
We got from client WSDL and XSD files only. Our task is to generate SOAP messages based on these WSDL and XSD files and extract SOAP bodies.
First step we should undertake is to generate client proxy files from given WSDL and XSD files. Main WSDL file has mulitple imports and imported XSD files also have some imports. I've tried to accomplish client proxy files generation by using SvcUtil.exe utility, but the error came up.
I ran SvcUtil.exe in this way:
E:\Projekti\WCF\XSD>svcutil /noconfig rosrazna.ru.xsd.SmevUnifoService.wsdl roskazna.ru.xsd.ResponseTemplate.xsd roskazna.ru.xsd.PGU_ImportRequest.xsd roskazna.ru.xsd.PGU_DataRequest.xsd roskazna.ru.xsd.PGU_ChargesResponse.xsd roskazna.ru.xsd.ExportPaymentsResponse.xsd roskazna.ru.xsd.ExportIncomesResponse.xsd roskazna.ru.xsd.ExportQuittanceResponse.xsd roskazna.ru.xsd.Ticket.xsd
But, this error came up:
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.2152]
Copyright (c) Microsoft Corporation. All rights reserved.
Generating files...
Warning: No code was generated.
If you were trying to generate a client, this could be because the metadata docu
ments did not contain any valid contracts or services
or because all contracts/services were discovered to exist in /reference assembl
ies. Verify that you passed all the metadata documents to the tool.
Warning: If you would like to generate data contracts from schemas make sure to
use the /dataContractOnly option.
I have to mention I did not put imports from XSD files imported in main WSDL file in SvcUtil.exe command. I don't know how to put them.
So, how to solve this?
Thank you in advance.
Goran
#Goran, copy all the referenced xsd files to the same location as the wsdl. Then, when using the svcutil from command prompt, list all the xsds there, or put a *.xsd, like this:
E:\Projekti\WCF\XSD>svcutil /noconfig goransWsdl.wsdl *.xsd
PS: You already seem to be mentioning all the xsds though.

Is it possible to xcopy deploy the Microsoft ReportViewer web control?

I'm trying to setup Microsoft reporting on a shared hosted server. I've set up the web.config files with the necessary entries and uploaded the assemblies Microsoft.ReportViewer.Common.dll and Microsoft.ReportViewer.WebForms.dll as well as the file Microsoft.ReportViewer.xml via FTP.
The site loads OK, but when I try to load a report a get a missing reference to Microsoft.ReportViewer.ProcessingObjectModel.dll. If I can get a hold of a copy of this dll, can I expect the report view to work? If so, what's the best way to get a copy? Or should I start trying to cajole the server administrator to run ReportViewer.exe?
This project is using Visual Studio 2008.
It appears that the answer is yes. I had never extracted a file from the GAC before, but it was pretty easy by following the command line method described in this question. Once the correct version of Microsoft.ReportViewer.ProcessingObjectModel.dll was extracted from the GAC on my development machine and uploaded to the site, the reports started working.

SSRS 2008, custom dll, file not found

I've been fighting with SSRS now for a while and it's beyond silly. When I add a reference to a dll (which is part of the same solution) it gives me nothing but a
[rsErrorLoadingCodeModule] Error
while loading code module:
‘MyFile.MyClass.Code, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null’.
Details: Could not load file or
assembly 'MyFile.MyClass.Code,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' or one of its
dependencies. The system cannot find
the file specified.
I've tried hitting the solution config to tell it debug source is in other locations, copying the file to about 50 different locations (not gac, not possible), running Visual Studio 2008 as admin, all the goofy stuff you can think of ... nothing, same error everytime.
Any ideas?
Here is the actual correct answer.. I've had to fight with this twice now and did not document it well enough the first time thinking it was a one-time thing.
Putting it in the SQL Server Bin folder is for the server. for DEVELOPMENT put a copy in the Visual Studio folder,
something like:
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies
or Windows 7 64 bit
C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies
I got a similar error on ssrs-2005.
Just manually copy your dll to the following report server folder: "C:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportServer\bin" and everything should work fine.
You may need to add references to the assemblies that your MyFile assembly itself references. So, if MyFile references System.IO for example, you may need to add that dll reference explicitly to the report.
For those who have been having trouble with custom dlls which import System.Data.SqlClient, I found the following tip absolutely essential in the rssrvpolicy.config file:
Short and dirty answer: Change the PermissionSetName attribute from
"Execution" to "FullTrust" for CodeGroup
"Report_Expressions_Default_Permissions".
I hope this helps someone.