Getting "Generate serialization assembly" to work - c#

I am in charge of a desktop WPF application, using a few web services (via Service References of the project).
Due to a Cannot execute a program. The command being executed was \"C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\csc.exe\" /noconfig /fullpaths #"C:\Documents and Settings\admin\Ustawienia lokalne\Temp\btucqeci.cmdline" error on a client's machine (which I understand is caused by csc trying to compile objects for the webservice request on the fly, and failing due to insufficient permissions), I hoped I could use a solution that I came across somewhere and enable the Generate serialization assembly option in the Build / Properties tab of my project.
It won't build, though - I keep on getting a compile error Could not find file 'E:\xxxx\xxxx\obj\Debug\xxxx.XmlSerializers.dll. Well I know it's not there, creating this DLL is precisely what I'm trying to achieve.
All the code for communicating with web-services is auto-generated and I haven't modified it at all.
I tried using sgen to achieve the same result "manually", but with no luck: I'm getting Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Could you point me in right direction? If additional information is needed, I will supply it. It's the first time I ran into this type of issue, so I'm a bit in the dark.
By the way, I have a (remote) access to the client's computer, but I failed to resolve the problem by resetting permissions. They run the program on an admin account and permissions do not seem to restricted in any way (based on what I googled up, including this question, I suspected the infamous IIS lockdown effect).

Related

An attempt was made to load a program with an incorrect format whenever i try to browse service from IIS

I am trying to browse an WCF servcice but whenever I browse the .SVC file, I always get the error as:
Could not load file or assembly 'ExternalBinaries.Boost' or one of its dependencies. An attempt was made to load a program with an incorrect format
Although I've tried all the steps to resolve this via all the previous posts related to it but without luck. Below are the steps that I followed:
Set Enable 32 bit applications to True in IIS
Setting the Target CPU to AnyCPU,X64 & X86 in visual studio
Copying the required DLL's to the specified location.
Rebuild the Application, Restart VS2015
None of the above steps yielded result. Can anybody guide to take this forward

Visual Studio: Various Service/DLL Reference Errors in Project

When trying to build a solution I've recently downloaded from source control (TFS in this case), I'm having all sorts of issues which other developers are not.
Sometimes, the project will build. Other times, it will not.
In general, I'm unable to make any source code changes, because as soon as I do, all the web & service references in the project appear to be broken. Re-adding the references does not fix the issue.
The service reference errors will appear as "The type or namespace could not be found..", while at other times I will randomly get "Could not load file or assembly..".
What is going on here? It doesn't appear to be project configuration related.
In this case, the overarching problem was Impersonation. The impersonation account was trying to access many local files during the build, which was surprising to me.
You can check if impersonation is used in a project/site by checking the web.config (that is used in your development mode - if you use web.config transformations check your Debug/Release configuration) for:
<identity impersonate="true" userName="XXXX" password="XXXX"/>
If impersonation is enabled, the impersonation account will need various access on your local machine.
In my case, the impersonation account needed full control to the following locations:
C:\Users\MYUSERNAME\Documents\IISExpress\
DRIVE:\SourceControlProjectLocation\
C:\Windows\Microsoft.NET\Framework
C:\Windows\Microsoft.NET\Framework64
C:\Windows\Microsoft.NET\Framework\VERSION
C:\Windows\Microsoft.NET\Framework64\VERSION
C:\Windows\Microsoft.NET\Framework\VERSION\Temporary ASP.NET Files
C:\Windows\Microsoft.NET\Framework64\VERSION\Temporary ASP.NET Files
This was a real pain because because inheritance was broken by default in many of these locations by Windows itself.

Orchard CMS failing to discover resources defined in a theme after Publish from Visual Studio

So, I tried to Publish (both Web Deploy and File System) an Orchard instance. I have quite a few custom modules and a custom theme. I have ResourceManifest : IResourceManifestProvider in my theme's project. Yes the theme has its own project and it is included in the solution.
The Scripts and Styles I defined are working beautifully when I debug it and work on my dev environment. So far so good.
Today I tried to setup a test environment of the current version. So I tried to get only the most essential without copy/pasting the whole folder structure. Naturally I tried to Publish the Orchard.Web project. And after a short struggle to get right permissions applied...it worked and I could access the site. Unfortunately when I navigated to one of my custom pages that has Style.Require("Resource defined in the theme") it crashed with an error message that a resource with the name "bla bla" cannot be found.
I tried to Publish both a Debug and a Release configuration but it didn't help. I tried to move the styles from the Theme project to a more concrete CustomModule but it didn't discover it.
Could it be some caching? Should I restart the IIS or only the WebSite in IIS? Somehow these new definitions cannot be detected.
In the end I tried to use Style.Include and it seemed that it won't crash, only to see that when I navigate to my page I receive "The page does not exist message" in the Content area (at least didn't crash)...
I am totally lost with this issue. Any help would be appreciated. I can give you more detailed info just let me know what.
I am running Orchard v.1.8.1.0.
This is my code:
manifest.DefineScript("Bootstrap").SetUrl("http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js");
manifest.DefineStyle("Bootstrap").SetUrl("http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css");
Error message:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: A 'stylesheet' named 'Bootstrap' could not be found. at Orchard.UI.Resources.ResourceManager.BuildRequiredResources(String resourceType) in
EDIT 03.01.2017
I have abandoned my efforts for quite a while. Today I decided to start battling it again and I found the following:
I moved the resource definitions from the MyThemeProject/ResourceManifest.cs to NonThemeCustomModule/ResourceManifest.cs file (one that I wrote).
I Rebuild and Re-Published using Web Deploy
And it was working!!!!
Which is pretty cool and solves my issue, BUT also is quite unexpected, since I have the same definitions twice and Orchard doesn't complain about it. Which leads me to believe that the ResourceManifest file in the theme is not taken into account for some reason. If anyone from the Orchard team can tell me what I am doing wrong, or if it is a bug of Orchard, that would be great.
Cheers!
I've encouter this situation a couple of time with a different scenario tho. In Orchard the application pool may need to have the rights on the folder where ur ressources are stored. Add it to ur security folder, it may be the problem.

Issues publishing wcf service - oracle.dataAccess error

I have an application that has a UI layer, wcf layer that interacts with the database layer. They are all in the same solution but seperate projects within the solution. Each is setup to target x86.
My issue is i continually get the error:
Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.
There are 2 ways I can make this go away.
Create a new wcf project, copy in my code and create a reference in the UI layer. It then begins to work.
Skip referencing the wcf layer and reference the database layter instead. This is not the way the users want it to work however.
Number 1 will work as long as I do not do the following:
Attempt to publish (Publish to my local machine so the same place development is happening). When I try and publish the app and the wcf this causes the reference or the service it self i am not sure to completely break. if i blow the service away and try and create another service reference to it i get this error. The only way I have found to make it go away is to create another project and copy the code as i mention.
I think i have everything installed correctly as like i mention, it all seems to work without issue until i publish (only local as i mention at this point.). I am a little concerned that when I publish to the server that I am going to have issues like this so only attempting this locally currently.
I should also note that when I am publishing this to my local IIS i am setting the reference app pool to enable 32 bit applications too.
Anyone know what I am doing wrong or how to get this to publish correctly?
Thanks for the help.
Ensure that your reference to the Oracle dll in properties is set to copy local.

How do I set switches normally defined in app.config in the C# Interactive window?

I'm trying to load a DLL with the C# Interactive REPL (from Roslyn). It throws the following exception:
"An attempt was made to load an assembly from a network location which
would have caused the assembly to be sandboxed in previous versions of
the .NET Framework. This release of the .NET Framework does not enable
CAS policy by default, so this load may be dangerous. If this load is
not intended to sandbox the assembly, please enable the
loadFromRemoteSources switch. See
http://go.microsoft.com/fwlink/?LinkId=155569 for more information."
The DLL is not on a network location, so I don't know why this exception is being thrown. Regardless, there is no app.config file for me to modify (to my knowledge), so does anyone know how I can resolve this error?
UPDATE:
I've unblocked the assembly, which makes this exception go away. But I'd still like to answer the more general question of how do I set switches normally defined in app.config in the C# Interactive window?
The assembly in question doesn't need to be on a network location at the time you try to load it. The message you're seeing is warning you that the assembly you are trying to load was (at some point) downloaded from the internet and is currently marked as untrusted.
To your meta-question, most config settings map to one or more code constructs (API's, attributes, etc.) that allow you to programmatically adjust the settings to your needs. How to modify particular settings depends on the setting and the API it affects. In some cases, you might need to write code to configure the runtime, in others you might have to configure IIS, logging and tracing, WCF endpoints, etc.
If you read the article linked to above, you'll find the following:
If an application has been copied from the web, it is flagged by Windows as being a web application, even if it resides on the local computer. You can change that designation by changing the file properties, or you can use the element to grant the assembly full trust. As an alternative, you can use the UnsafeLoadFrom method to load a local assembly that the operating system has flagged as having been loaded from the web.
Using UnsafeLoadFrom may be safer in general than enabling your app to download any arbitrary assembly from an untrusted source and have it run with full trust inside your app.
The docs go on to say:
This element is typically used in the application configuration file, but can be used in other configuration files depending upon the context. For more information, see the article More Implicit Uses of CAS Policy: loadFromRemoteSources in the .NET Security blog.
Read this latter document carefully - it illustrates the code you need to write to effect the same outcome as setting the loadFromRemoteSources config flag: HOWEVER, don't underestimate the dangers of loading arbitrary code into your apps!

Categories

Resources