diffculty implementing EFCodeFirst.CreateTablesOnly / DontDropDbJustCreateTablesIfModelChangedStart - c#-4.0

I'm having difficulty implementing EFCodeFirst.CreateTablesOnly (changed to DontDropDbJustCreateTablesIfModelChangedStart).
I have successfully pulled in the package using NUGET. Now there is a mention of
in packages.config
and a DontDropDbJustCreateTablesIfModelChangedStart.cs
I've added Devtalk.EF.CodeFirst to references
in my app_start directory.
But I still can't make use of the DontDropDbJustCreateTablesIfModelChangedStart class. When I do, the app dies with msg
Could not load file or assembly 'EntityFramework, Version=4.1.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
When I check definition of DontDropDbJustCreateTablesIfModelChangedStart, I find it only has a signature and not a definition.
What did I do wrong? Or what step did I leave out? Am I supposed to Implement the Class/Method?

The problem is that library was probably compiled with EntityFramework.dll version 4.1.0.0 and author didn't update it for version 4.2.0.0 and 4.3.0.0. Try to redirect version 4.1.0.0 to version 4.3.0.0 in your web.config file.

Don't Use it use EF's Migrations:
http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-released.aspx

Related

Excel Plugin no longer works after adding nlog (installed with addin-express)

I recently implemented some logging with NLog which I installed through NuGet. This works fine on my local machine during debugging.
Now when I (or anyone else) attempts to install our add-in, the add-in is not present in Excel. There is no error messages, no log file evidence, but the add-in is present in the Control Panel.
The add-in also does not appear in the File > Options > AddIns > COM panel of excel.
Edit: Found a log file in %TEMP%.
Exception Source: MyPlugin
Exception Type: System.IO.FileLoadException
Exception Message: Could not load file or assembly 'NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Exception Target Site: .cctor
So how do I tell addin-express to use the nlog file from nuget?
Turned out that the Addin-Express install was faulty. We had to uninstall and reistall it then the dependencies were properly bundled with the plugin install.

Can custom DLLs in Azure Functions depend on Nuget packages in project.json?

I have a custom DLL which depends on packages in project.json. I am getting the following error:
2017-05-25T21:04:18.152 Exception while executing function:
Functions.TimerTriggerCSharp1. mscorlib: Exception has been thrown by
the target of an invocation. f-TimerTriggerCSharp1__631134587: Could
not load file or assembly 'MyAssemblyName, Version=MyAssemblyVersion,
Culture=neutral, PublicKeyToken=MyAssemblyToken' or one of its
dependencies. The system cannot find the file specified.
I've added the assembly in the bin/ folder and am referencing it with the full path. The assembly depends on other Nuget packages that I defined in project.json.
Any idea why I'm getting the error?
The general guidance/recommendation is to deploy your transient dependencies with your assemblies.
In the case of NuGet dependencies, the runtime will resolve that for you, but the runtime will attempt to fulfill those dependencies, but please make sure you change your assembly reference from using the full path to using the simple file name (without the path) only, like:
#r "MyAssembly.dll"
The runtime will automatically load the assembly from the bin folder as a private dependency, which will scope the dependency to that function and attempt to use the function's referenced packages to fulfill transient dependencies.

Can't compile SocialBootstrapApi

I downloaded the SocialBootstrapApi from GitHub but I can't run the example.
When I try to run it I get:
Severity Code Description Project File Line Suppression State Error CS0234
The type or namespace name 'Helpers' does not exist in the namespace 'System.Web'
(are you missing an assembly reference?) SocialBootstrapApi
Severity Code Description Project File Line Suppression State Error CS0234
The type or namespace name 'Mvc' does not exist in the namespace 'System.Web'
(are you missing an assembly reference?) SocialBootstrapApi
When I look at the Global.asax.cs file it looks like it's missing s reference to System.Web.Mvc. Nuget shows it as being installed. I tried installing several versions of MVC, still won't compile.
The read me file said to add:
<add namespace="ServiceStack.Mvc" />
to the web.config file, which I did, but it still won't compile.
Any idea what I'm doing wrong?
-Eric
The System.Web.Helpers namespace was left over from its original MVC 3 template which used to be automatically installed by older versions of VS.NET in your GAC and can be installed using Web Platform Installer.
But SocialBootstrapApi doesn't need these namespaces so I've just removed them in this commit. You should be able to pull the latest version of SocialBootstrapApi or just delete the namespaces manually. Otherwise installing MVC 3 will also work.

Why does R# tell me "Cannot resolve assembly System.Drawing" when I am referencing System.Drawing?

When I run "Inspect > Code Issues in Solution", R# tells me "Cannot resolve assembly System.Drawing" and points to this line of xml in a *.resx file:
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
I looked at my System.Drawing assembly in my project's list of References. It is version 3.5.0.0, not 2.0.0.0, so I changed the version number in the xaml in the .resx file from 2.0 to 3.5. That still elicited the same warning from R#, though.
So then I thought maybe it was the PublicKeyToken that was the culprit; so I changed that value from "b03f5f7f11d50a3a" to "969db8053d3322ac" (as found here); but then the project wouldn't even build; I got:
Invalid Resx file. The located assembly's manifest definition does not match the assembly reference.
Although these "issues" exist, the app seems to be working okay - the image that follows the assembly alias:
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
blee blah bloo
</value>
</data>
...displays fine.
Still, when R# raises its finger, it makes me nervous; how can I rectify this flubup?
NOTE: This is a Visual Studio 2008 Windows CE/Compact Framework app.
I had a similar problem in the resx file in one of my C# projects:
Once I installed the relevant reference (System.Windows.Forms etc) - for that project - that particular resharper issue went away:

How does a nuget package specify copylocal

I have issues that I am dealing with where certain nuget installed package added via VS2012 have the copylocal value set to true where as others don't have any value set.
How does nuget know when to add copylocal and not to?
Is there some setting that I am missing in the nupkg file that I am missing?
I had a look at the source code for nuget (briefly) and it the copylocal value exists then it should be set to true.
e.g.
Install-Package System.Web.Mvc
resolves to
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll</HintPath>
</Reference>
However
Install-Package Newtonsoft.Json
Resolves to
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.5.0.6\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
I kind of figured this out.
The answer lies partly here:
http://msdn.microsoft.com/en-us/library/vslangproj.reference.copylocal
Although "Newtonsoft.Json" doesn't have the copylocal=true explicitly set in the csproj file, it seems the visual studio evaluates automatically when copylocal=true is set or not.
It seems nuget relies on the DTE integration to help it determine the value for copylocal.
I tested this out by running msbuild out of VS2012, removing System.Web.MVC from the GAC and it is copied to the bin dir.
I guess this only becomes an issue when one wants to open a compiled website the dll doesn't exist in the bin e.g. System.Web.MVC.
VS in this case does not know it should look in the GAC.

Resources