Using System.Web.Helpers in a WPF desktop application - json

I have been working on a WPF desktop application remotely. Everything has worked great so far, but recently I had to move some functionality from a web application to the WPF application. It uses the System.Web.Helpers.Json class to decode some JSON that comes from a website CMS system.
I therefore added a reference to the System.Web.Helpers dll to the project along with the relevant code and when I ran it locally, it all worked fabulously. Unfortunately, after deploying it using Click Once, the users got the following error:
So I added a reference to the Microsoft.Web.Infrastructure dll file to the project, ensured that it would be copied locally and then deployed a new version of the application. Unfortunately, the following day, I was presented with a new error:
I've searched online and found that if I add a reference to the System.Web.Razor dll, then that will in turn require a reference to the System.Web dll. My problem is that due to time constraints, I only get to make one change a day and this needs to be fixed as soon as possible... if I only get informed about one missing reference each day, then I could run out of time really easily.
So my question is does anyone know all the references that I will need to add to satisfy the System.Web.Helpers dll?

I've just come across this question and realised that I never updated it with an answer. Unfortunately, this was asked a long time ago, so I can't be 100% sure of this answer now, but from what I can remember, I needed to add these following DLLs in order to use the System.Web.Helpers assembly:
Microsoft.Web.Infrastructure
System.Web.Helpers
System.Web.Razor
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
There is a possibility that you'll also need the System.Web and System.Web.WebPages.Administration assemblies, but I can't be 100% sure about that now.

Related

How to reference a DotnetStandard 2.0 library from another DotnetStandard library?

I have started a project to move some framework libraries targeting Dotnet 4.6.1 to DotnetStandard. I am using VS2017. I started with a relatively simple library which did not have any nuget references and only couple of classes. The approach I took was,
Create a new DotnetStandard 2.0 library project. Just to make sure I have a clean slate instead of manipulating the csproj file of the existing project.
Copy the code files from the old to the new project
Make any code changes required to make the new project build
This worked pretty smoothly. Now, I started with a second library that referenced the first one. I followed the same steps as mentioned above. At Step 3, however, I am hitting roadblock. I am unable to get the namespaces exposed by the first library in the second library, whatever I do. I have tried these,
Referenced the First project from the second project as Project Reference
Created a nuget package for the first project, hosted it in a local folder and installed the package in second project.
Both ways, I am unable to get the namespaces and classes from the first project.
What am I doing wrong?
UPDATE
I tried creating a dummy solution and tried creating two Dotnetstandard projects there. Project referencing worked fine there. So, to experiment, in my actual solution, I deleted the second project and created again. That somehow resolved my issue and I am able to successfully add nuget as well as project references now. Not sure what the problem was earlier.

metadata tag not found with describeType in production

I am using describeType and am able to get all of the variable and accessor metadata tags just fine in local debug, local test suite or local air build. Our web app running this code also sees the metadata just fine in production (running with browser plugin). But, our production air desktop app throws my error "can't find metadata". When I added some logging code (being thoroughly confused LOL) I discovered that the metadata property in the XML from describeType is empty?!?
My only thought is that we use gradle and run a bunch of custom scripts during the actual build process... but HOW could that be either removing or making unreadable class metadata tags?
I've tried standard v/s custom tags, accessors v/s variables, describeType(instance) v/s describeType(class) and all of these give same result... all variations work everywhere every time except in production desktop build.
Anyone with ANY thoughts on this... please chime in. I've been pulling my hair out with this one!
Thanks!!!
so it turns out my "only thought" was the correct answer. after digging deeper I found that the keep-as3-metadata that was on our compiler options was not up to date in our grade build scripts and didn't include the tags we were using for this. Thank god!!! LOL.

Box-API: How can I add a strong name to a 3rd party assembly written for the .NET Portable Subset

I am trying to strongly name a 3rd party API that I have the code for but it's using a 3rd party DLL/NuGet Package that is also not strongly named and I'm having a lot of trouble.
I'm using the Box Windows SDK and the API was written in the .NET portable subset and supports .NET for Windows Store Apps, .NET Framework 4 and higher, SL4 and higher, and Windows Phone 7 and higher. Granted, I do not need all of these but I do need the .NET 4 and Silverlight versions. The API already works wonderfully and runs fine on its own. It would with my application also, if all my projects were unsigned but they aren't. We use strongly named assemblies for our Silverlight application in order to make use of application library caching.
Anyway, I have the source code for the API so I simply added my PFX file to the project to sign it. I then get an error that a dependency that this API is using called NitoAsnycEx.dll is not signed. I do not have the code for Nito.AsyncEx.dll but normally this isn't such a problem, more of an annoyance. So now I have an age-old problem of needing to take a 3rd party DLL of which I don't have code for and sign it with my PFX or another SNK file.
I can do either and normally I use one of the processes so wonderfully explained in this post by Ian Picknell: http://ianpicknell.blogspot.com/2009/12/adding-strong-name-to-third-party.html. So I have followed that process and the IL signing tools seem to sign the DLL just fine.
To make a long story shorter, let's use the simplest version of the signing process where I already have a simple SNK file ready to go. Basically, I do this:
I can run ILDASM to get the .il file for this 3rd party EXE:
ILDASM Nito.AsyncEx.dll /out:Nito.AsyncEx.il
I can then run ILASM to get the signed DLL:
ILASM Nito.AsyncEx.il /dll /resource=Nito.AsyncEx.res /key=NPSAssemblyKeyNoPassword.snk
It works great and I get this result:
Method Implementations (total): 118
Resolving local member refs: 0 -> 0 defs, 0 refs, 0 unresolved
Writing PE file
Signing file with strong name
Operation completed successfully
So now I have a signed DLL. I go back to my 3rd Party API code and remove the old reference to NitoAsyncEx.dll and put a new one to this. I try to compile and then I get an error like this:
Error 44 The base class or interface 'System.Object' in assembly 'System.Runtime, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' referenced by type 'Nito.AsyncEx.AsyncLock' could not be resolved r:\Data\GM\Source\GrantManagement\GrantManagement\3rd Party\Nito\Nito.AsyncEx.dll
I figure there is some problems using the portable .net library here but I'm not sure what it is. This same process normally works for me for Silverlight 4+ and Full .NET 4.5 framework libraries. Is there another ILASM or ILDASM set somewhere that will disassemble and reassemble the portable code correctly? Is this even possible?
I also tried to go and get the source code for the NitoAsyncEx.dll, which is open source btw, and compile it but that source code will not compile as it's missing some files. So currently I'm stuck with my integration of this API into my project and need a little assistance from any experts in the community.
Is there a way to sign this DLL correctly so we're not missing references to basic classes such as System.Object?
Is there a way to get around needing to sign this DLL at all and having it referenced from my projects?
UPDATED
The Box SDK has been updated and is now strong-named on nuget. This is thanks to the recent update to AsyncEx which strong-named the assembly.
As you mentioned, it's unfortunately out of our control that the NitoAsyncEx library is not strongly named. This library provides the ability to properly lock resources during an async/await call, and I do not believe there is a better alternative at the moment.
This being said, I may have a (hopefully temporary) workaround for you. I've downloaded the source from https://nitoasyncex.codeplex.com/ and was able to get it to compile. These are the steps I performed:
Removed the reference to MSBuild in the csproj
Copied the missing Dequeue.cs file from the packages folder
Resolved missing nuget references
Regenerated the AssemblyInfo.cs
Excluded the .tt template files from the project
Unloaded all other projects the SDK does not use
Here's the resulting solution:
https://cloud.box.com/s/7ikurtyajqmhq9p8q52x
I've successfully ran the resulting dll through the SDK's tests so hopefully this should cover what you need. I cannot guarantee the stability of this method, but having a working source should allow you to do any signing you need. From there, you should be able to drop the signed assembly into the SDK source and sign that assembly as well.

Changes To xaml don't reflect on App Until rebuild - windows phone

I have a weird problem in an windows phone 8 project (Visual Studio Express for windows phone 8) that Changes to xaml( ex:change visibility of control) don't reflect on App until I rebuild the project and deploy it again to emulator or device.
The changes reflect normally in the design window of visual studio but didn't reflect on the running App.
I did many researches and they didn't help, like:
1- Change "Build and Run" to "always build" when projects are out of date.
2- I checked configuration manager as This post suggests but it was selected.
I have the exact same issue. I have a work around at the moment to save the hassle of rebuilding the solution because rebuilding deletes and re-installs the app and changes any saved settings you've made while debugging. The work around is to switch between configurations. So I'll execute the app in Debug, make some changes, then the next time I execute I change config to Release, and the changes are there.
The difference I can see is when it works I can see the Build Output line which says "Updating the application as the manifest file has changed..." take a few moments to complete. When this issue occurs the output line appears for a split second and so you can tell the incremental deployment hasn't actually been deployed to the device/emulator.
This is a little frustrating so hopefully someone has a real answer. I have other projects on the same machine and they don't have this issue. Just the one project so I don't think its a VS2012 problem.
I've also tried suggestions from other sites saying delete bin and obj folders but that didn't work.
I had the same issue for some of my WP8 Silverlight projects in VS 2013. I couldn't understand why it happened only for some projects but not all, but eventually I found this forum thread. The solution is the following: if the name of your app includes spaces, you definitely need to remove them or replace say with the underscore char. This recipe helped to recover my 'problem' projects.
I also noticed that numbers at the beginning of app name cause the same problem. I solved it by removing numbers from solution and app name.

Why isn't FlashBuilder building with updated code?

I am using FlashBuilder for a project (Actionscript Project, using AS3) that I've been working on for a few weeks now. I took a break for the holidays (naturally), and when I came back, the compiler seemed to stop working. Everytime I ran the default Actionscript application, the swf ran without my new changes.
According to the file system, the swf had been modified (though my SVN software, Cornerstone, detects no difference in the file). But, if I add in a trace statement in the constructor of the default application, it is not displayed in the console while running in debug mode (even though all other statements that were written and saved before today run fine).
I have tried Project->Clean several times. I also have changes the compiler arguments to generate a size report, however, I have another swf that is generated on build (a preloader) and the size report only includes that (even though it does modify the main swf. This even happens after a clean and it MUST generate a new main swf and preloader swf).
I have also restarted FlashBuilder, and the computer, and moved the project to a different computer, all with the same result (build not including updated code)
Any other ideas to get rid of this strange behavior?
Thanks in advance,
-Esa