Entity Framework in Partial trust environment - linq

I know that Entity Framework supports Partial trust, I personally blogged about that
It was working fine, I tested it and it was fine. Now if you download the samples attached to my post about the subject, it doesn't run under default partial trust anymore!!!
When I dug into System.Data.Entity assembly using reflector on the position of failure "System.Data.Objects.LightweightCodeGenerator.ValidateSetterProperty(RuntimeMethodHandle setterMethodHandle, MethodInfo& setterMethodInfo, Type& realType" I noticed that it calls RuntimeMethodHandle.Value property which has the following attribute on get accessor "[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)]"
So I went to my medium trust configuration and added another flag "UnmanagedCode"
""
I test the application again and it worked fine.
Now what is this all about?! It was working before so why now not it is not! There is something missing!!! Does System.Data.Entity changed during the several frequent updates post to of VS.NET 2008 SP1 and the latest one was made on Last August 2009. Because before that date, it was working fine.
So I would appreciate if any could clarify this and guide me if I am wrong, or there is something that I am missing.

It sounds like you have definitive proof of a breaking change to Entity Framework. I would go to http://connect.microsoft.com/ and report a bug. It would probably help if you could confirm that a change was made by finidng the old assembly without the "UnmanagedCode=true" attribute. Include both versions in the bug report.
Incidentally, I just looked at RuntimeMethodHandle in Reflector. The get accessor for Value returns "this.m_ptr;" and has no attribute decorations. It's in mscorlib, my version is 2.0.0.0 (I'm running .NET 3.5 on my development system.)

Diego Vega PM in Entity Framework team responded to this issue in Entity Framework forums with the following
Hello Muhammad,
We are aware of an issue in the build
included in Windows 7 and Windows
Server 2008 R2 that prevents Entity
Framework from working in Medium
Trust.
Both the version of mscoree.dll and
the exception message you describe
match the scenario.
We expect to have a solution before
mainstream adoption of Windows 7 and
Windows Server 2008 R2, but in the
meanwhile the recommendation is to
keep using Windows Server 2008 or
Windows Vista for testing and
deploying of EF based applications in
Medium Trust.
Hope this helps, Diego

Related

how to create my own installer which check for .net framework

I created an Windows application with .Net Framework 2.0. I want to install it on different users systems. I Created an installer with some software and working fine.
Now I want to develop a simple .exe builder which checks the .Net Framework requirement.
How to proceed, please help me.
To get started, you can look into the registry to see if certain keys are present.
According to MSDN's page on this topic, the keys are stored in
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP
Also, just as a side note, if .NET framework is not present, standard .net assemblies already give you an error message (which doesn't look very nice, but it still exists).
And another thing you want to consider is if you actually want to create your own installer when you can use existing ones that have this kinds of checks built-in. InstallShield is an example for that.

Upgrading from Web API RC to Web API RTM

I have seen that yesterday Web API RTM has been released by Microsoft.
However I can't seem to find any log about what has changed from RC to RTM and any tips on what has changed.
We have a service that's ready for production next week, and I am not sure whether to roll with RC or upgrade to RTM this late in the project. What value does it add?
Thanks
Ubal
The official release notes can be found here at www.asp.net.
As #Aliostad kindly mentioned, I wrote an overview post highlighting what's changing and including some code samples and other references.
Henrik also wrote a nice overview post - and that one's also focused on the preview for the out-of-band functionalities available as NuGet packages (OData, tracing, Help page, and a formatting library for Win8).
If you ask whether you should upgrade - obviously yes. There aren't many breaking changes so it should be rather painless, and you get a mature, production-deployable product. It's well worth it imho.

Using a WinForm as a Windows Installer Custom Action

I am working on in installer project that needs to gather some info and act on it during the install (mainly online key retreival and registration). The Setup Project UserInterface templates seem inflexible and poorly documented so I am looking at opening a WinForm as a Custom Action.
I know this is possible because I see reference to it in many places but this is my first Windows Installer experience and so far it is mired in googled contradictions, partial or outdated information and guesswork... erg....
Does anyone have (even a pointer to) a clear concise description of how one gets this done in a VS 2008 WinForm project...
Many thanks for inputs
There is no guarantee that the .net framework is installed when the installer is launched (especially on Windows XP). A best practice is to keep your installer away from any dependencies.
Put the online key retrieval and registration in your application rather than doing all that stuff during install.
Create a standard installer class. In the class create your form and show it (ShowDialog is prefered)

Validation issues deploying from local machine's IIS 5.1 to Web Server's IIS 6.0

I'm developing a VB.NET 1.1 web application. All validation and RegEx controls work perfectly when testing on my local machine using IIS 5.1, however when I deploy to our "leased" web server utilizing IIS 6.0 I'm either getting a "System.FormatException: String was not recognized as a valid DateTime" error on the date fields (worked on local machine), or the other non-date validation and RegEx controls do not get recognized until after submtting the form, in which the data had somehow already posted to the database by this time.
I was not aware that I would be using a different version of IIS once deploying into the testing/production environment, and higher-up help is nonexistent or less knowledgeable.
I've added the dumbed-down and longer-written conditional logic to bypass this validation issue for the meantime because I'm not having much luck googling the proper resolution, nor finding it here yet. Please advise on what I may be missing out on knowledge-wise with validation or perhaps what the functional differences between IIS 5.1 and 6.0 would be that I may look further into.
I apologize if this is too broad of an issue description, my mind is malf-helted by now.
Thanks!
I cannot remember the exact specifics on this, and I might have to go digging deep to try and find it. But the root cause is due to a slightly different build number on the .NET 1.1 framework between your local machine to the actual production web server.
I had this issue a few years ago, we synced the .NET patches, and we got it to work

Can ASP.NET AJAX partial rendering work inside a SharePoint 2007 application page?

I have a simple page with my ScriptManager and my UpdatePanel, and my ContentTemplate has one ListBox and one Label. I am just trying to catch its OnSelectionChanged so I can update the text in the Label. No matter what settings I try to tweak, I always get a full-page postback.
Is this really not going to work, or am I just screwing this up?
You need to have Sharepoint 2007 service pack 1 -- or else there's no chance.
(Sharepoint 2007 predates ajax 1.0 -- they built some support into service pack 1)
Next, from a trouble shooting point of view, test that the exact same code functions as expected when hosted in a regular asp.net page. (Literally copy and paste your code across into a fresh page, to rule out any typographical errors). Ruling sharepoint in or out of the problem area will help narrow down the solution space.
If you have installed SharePoint 2007 (without Service Pack 1) then you can follow an example like the following article:
AjaxBasePart: Easy ASP.NET 2.0 AJAX Extensions 1.0 and Office SharePoint Server 2007
The reason for this is that there exists a specific problem with mixing doPostback, UpdatePanel and SharePoint -- and the symptom is exactly what you're seeing: a full-page postback instead of an asynchronous postback. See this KB article for a workaround: A Web Part that contains an ASP.NET AJAX 1.0 UpdatePanel control that uses the _doPostBack() ...
Otherwise you can just install Service Pack 1 to fix your problem:
Windows SharePoint Services 3.0 Service Pack 1 (SP1)
There's a specific problem with mixing doPostback, UpdatePanel and SharePoint -- and the symptom is exactly what you're seeing: a full-page postback instead of an asynchronous postback. See this KB article for a workaround: http://support.microsoft.com/kb/941955
Todd Bleeker at Mindsharp showed me a piece of code he wrote that can use Ajax on Sharepoint 2.0. It was pretty cool. I believe the company used it on their sharepoint site managment software if you want to take a look. (you used to be able to request a 30 day trial). I bet how to do it is on their yahoo group (I can't remember the name, but I am sure that if you search for mindsharp you'll find it.)
As a note, Ajax has been around for a long time. Microsoft easily supported it since 2002 maybe earlier with the release of IE 5.5 (I don't know about other browsers, I was doing internal development and we only supported ie at the time). It just wasn't called that. The term Ajax is nothing more than a marketing term that someone coined later on.
Getting the latest service pack for SharePoint 2007 will resolve your problem (and add full support for AJAX). Without the service pack you will need to follow an example like that outlined in this article:
AjaxBasePart: Easy ASP.NET 2.0 AJAX Extensions 1.0 and Office SharePoint Server 2007
Posting this hear so that people know there is an answer even without the latest service pack (secretGeek's response seems to say there is no chance).
From a technology standpoint, Service Pack 1 does not add full support for ASP.NET AJAX. You still need use the workarounds described in the various articles mentioned in the previous answers.
Particulary, you need to make sure that the web.config file for your SharePoint Web application has been updated to support the appropriate version of the ASP.NET AJAX Extentions.
The fact that the web.config had not been updated was the mostly likely cause of the problem described in the original question.

Resources