Showing posts with label Visual Studio 2012. Show all posts
Showing posts with label Visual Studio 2012. Show all posts

Friday, August 15, 2014

System.BadImageFormatException: Could not load file or assembly(Windows service)

Recently I have created a windows service and I wanted to to install that service to the my QA server.for that I used InstallUtil command.So for that below command in my command prompt.

image

But that command failed with below message

System.BadImageFormatException: Could not load file or assembly '{WriteOffService.exe}' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Then after my check dependencies those were placed fine.After I search I found the reason for this. Smile

I have complied my application according to the 32 bit configuration and I used 64 Bit installUtil to the install application. after I installed it using 32 bit installUtil and its worked as expected.

After you install .Net framework(in my case it is version 4.0) its created the two separate folders for 32 bit and 64 bit.In side those folders for according to the Framework version

Intallation root:\Windows\Microsoft.NET\

 image

(here you can see two different folders Framework(32) and Framwork64(64)).That each folder contains two InstallUtil versions according to the .Net Framework version.

image

64 bit version

image

32 bit version

Wednesday, October 30, 2013

Unable to update the EntitySet because it has a DefiningQuery and no element exists in the element to support the current operation.

 

Recently I got this error when I try to update table using Entity framework 5.

Cause :Reason for that is the target table does not have the primary key.So need to add the primary key to the target table.

Happy coding Smile

Thursday, October 24, 2013

LINQ to Entities does not recognize the method 'Boolean IsNullOrWhiteSpace(System.String)' method

 

recently I have used below query to get some filterded details from my table.

dbContext.ttable.Where(r => string.IsNullOrWhiteSpace(r.field))






but when I try to run above code snipped I got


“LINQ to Entities does not recognize the method 'Boolean IsNullOrWhiteSpace(System.String)' method, and this method cannot be translated into a store expression."”


after few minutes searching found the reason for that.


My query return type is IQueryable<ttable>.So this type is optimized to the deliver an optimized query.In this context all C# methods are not supported.There for I have to change the query like this and then it works Smile


dbContext.table.where.(!(b.field == null || r. b.field.Trim() == ""))

A processor named 'T4VSHost' could not be found for the directive named 'CleanupBehavior'. error VS2012 and EF 5

I install entity framework 5 to my 2012 project and create the EDMX using the already created Database schema.but project build was failed mentioning above error.so I search and found below solution.

Step 1: Go to below LOcation

s1

Step 2 :

Open EF.Utility.CS.ttinclude file and remove code part from it and save .

“<#@ CleanupBehavior Processor="T4VSHost" CleanupAfterProcessingTemplate="true" #>”

2