Could not load file or assembly 'Launch, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified : Migration Error - entity-framework-6

I have been working on Entity framework recently i'm facing some challenging like when attempt to run the migration command it will show this Error
"Could not load file or assembly 'Launch, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified"
please if can help with i will be appreciated a lot

in my case. I solved this error by correcting the spelling of my target project from where I was calling it in the extension of my services for the startup class.

In my case as well, the error was due to the project name being misspelt in my startup class within the ConfigureServices method.
public void ConfigureServices(IServiceCollection services)
{
Constants.connectionString = Configuration.GetConnectionString("DefaultConnection");
// Add framework services.
services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"),
b => b.MigrationsAssembly("ProjectNameHereWasMisspelt")));

Related

Using System.Collections.Immutable with F# and Mono

I am trying to make use of the ImmutableDictionary in F# using Mono. I'm using the Xamarin IDE.
I have set my target framework to Mono/.Net4.5 and imported the System.Collections.Immutable using the built in Nuget package manager.
The following line
open System.Collections.Immutable
is generating the following two errors
'/Users/UserName/Projects/Xamarin/OrderInfer/OrderInference/MyTest.fs(34,34): Error FS1109: A reference to the type 'System.Collections.Generic.IEnumerable'1' in assembly 'System.Runtime' was found, but the type could not be found in that assembly (FS1109) (MyTest)'
/Users/UserName/Projects/Xamarin/OrderInfer/OrderInference: Error FS1108: The type 'Lazy'2' is required here and is unavailable. You must add a reference to assembly 'System.ComponentModel.Composition, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. (FS1108) (OrderInference)
The 2nd error suggests I need to reference System.ComponentModel.Composition. Am I able to use it in Mono? If so, is there another assembly I need to reference?
EDIT:
Solution removed and reposted below as an answer
This problem can be solved by adding a reference to: 'System.ComponentModel.Composition'. In Xamarin's IDE, this is done by using the Edit References Dialog which can be found by right-clicking on the reference in your project. Go to the All tab and search for System.ComponentModel and just add the System.ComponentModel.Composition assembly.
I now have the following two assemblies installed:
System.Collections.Immutable.dll
System.ComponentModel.Composition.dll
My code now reads:
open System
open System.ComponentModel.Composition
open System.Collections.Immutable
type wordPairs = { pairs:ImmutableDictionary<string, string>; count:int}
let myPairs = {pairs = ImmutableDictionary.Create<string, string>(); count = 0}
Note: As gradbot pointed out (and Immo Landwerth later nitpicked about ;>> ), ImmutableDictionary is a abstract sealed class. And as such, it has no public constructors. So you need to use the .Create method.
ImmutableDictionary is abstract so new won't work. It does however provide a number of create methods.
ImmutableDictionary.Create<string, string>()

ESB 2.2 EsbImportUtil.exe The type initializer for 'Microsoft.Practices.ESB.Configuration.ConfigHelper' throw exception

when importing the itineries using ESB 2.2 EsbImportUtil.exe following error is displayed
I have EnterpriseLibrary 5 installed and GAC contain EnterpriseLibrary 4.1 dll also.
The type initializer for 'Microsoft.Practices.ESB.Configuration.ConfigHelper' threw an exception.[A]Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection cannot be cast to [B]Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection. Type A originates from 'Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.Practices.EnterpriseLibrary.Common\5.0.414.0__31bf3856ad364e35\Microsoft.Practices.EnterpriseLibrary.Common.dll'. Type B originates from 'Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.Practices.EnterpriseLibrary.Common\4.1.0.0__31bf3856ad364e35\Microsoft.Practices.EnterpriseLibrary.Common.dll'.
Thanks for the help
Have you made any changes to esb.config file. Added new orchestation, try removing it. I had similar issue; fixed by removing wrong configuration.
Check:-
http://social.msdn.microsoft.com/Forums/en-US/bf2446fd-87fb-462a-8b78-cde7026bfdf5/the-type-initialize-for-microsoftpracticesesbconfigurationconfighelper-threw-an-exception?forum=biztalkesb

Updating to last version of the monodroid and now the solution not builds

Today I update my monodroid to the its last version. Before this my solution works fine but no I got this errors:
MyProjectPath\Classes\Presentation Layer\Class Override\ImageLoaderListener.cs(15,15): Error CS0012: The type 'Java.Lang.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=c4c4237547e4b6cd'. (CS0012) (RPLAndroidApp)
and also this:
MyProjectPath\Class Override\ImageLoaderListener.cs(15,15): Error CS0012: The type 'Android.Runtime.IJavaObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=c4c4237547e4b6cd'. (CS0012) (RPLAndroidApp)
I tried to recompile my java library that I build by 'JavaBindingLibraryProject' and add them again to project but When I build them I get many errors.
I'm confused what should I do?
Rebuild all your projects with the new version of Mono for Android. You have to do this because of the changes in Assembly strongnames.

"A type load exception has occurred." using DbContext with MySql connector with Mono

I am trying to use the MySQL Database with the Entity Framework Version 4.1.0.0 and Mono 2.11.4 in a ASP.NET MVC 3 Project.
On my Local Windows system everything works great but when I publish it to my Ubuntu 12.04 LTS System I get a lot of errors.
First I get:
Could not load type 'System.Data.Entity.Infrastructure.DbUpdateException' from assembly 'EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
when I press F5 I get different errors every time the page refreshes:
Could not load type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' from assembly 'EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Could not load type 'System.Data.Entity.Infrastructure.DbCompiledModel' from assembly 'EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Could not load type 'System.Data.Entity.Infrastructure.ReplacementDbQueryWrapper`1[TElement]' from assembly 'EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Could not load type 'MySql.Data.VisualStudio.Editors.SqlEditor' from assembly 'MySql.VisualStudio, Version=6.6.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'.
Could not load type 'MySql.Data.VisualStudio.WebConfig.WebConfigDlg' from assembly 'MySql.VisualStudio, Version=6.6.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'.
A type load exception has occurred.
The last error occurred when I try to use the database with this code:
using (var db = new DefaultContext())
{
db.Persons.Add(new Person() { Name = "hallo", Address = "bllaaa" });
db.SaveChanges();
var persons = db.Persons.ToList();
return View(persons);
}
Did anybody have a similar problem and solved it? I do not know what to do.
P.S.: I use Code First Migration
From my understanding, Mono is bundling the open source version of Entity Framework, which is essentially yet-to-be-released v6.
http://weblogs.asp.net/scottgu/archive/2012/07/19/entity-framework-and-open-source.aspx
So it would seem you can't target EF v4.x, since the code has likely undergone major changes. Although, if you discover that the seemingly missing types are still there, you could attempt to work around the issue with an assembly redirect (just search for bindingRedirect).
I know why this happend.
I installed the mono-fastcgi-server4 through apt-get after i installed mono from source. So i had 2 mono versions installed and the older one was active. (2.10.8)
And the Entity Framework seems totally useless to me because only the new EF6 works with a database but there arent any provider who suppot EF6 and work with mono.

Activation error occured while trying to get instance of type LogWriter, key ""

I am getting this error while loggin into eventviewer. I am looging the exception in event viewer as well as rolling flat file. If i remove the eventviewer section then rolling flat file works perfectly, but only when i add this it gives the exception
{"Resolution of the dependency failed, type =
\"Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter\", name =
\"(none)\".\r\nException occurred while: while resolving.\r\nException
is: InvalidOperationException - The type TraceListener cannot be
constructed. You must configure the container to supply this
value.\r\n-----------------------------------------------\r\nAt the
time of the exception, the container was:\r\n\r\n Resolving
Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl,LogWriter.default
(mapped from Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter,
(none))\r\n Resolving parameter \"structureHolder\" of constructor
Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl(Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder
structureHolder,
Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider
instrumentationProvider,
Microsoft.Practices.EnterpriseLibrary.Logging.ILoggingUpdateCoordinator
updateCoordinator)\r\n Resolving
Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder,LogWriterStructureHolder.default
(mapped from
Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder,
(none))\r\n Resolving parameter \"traceSources\" of constructor
Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder(System.Collections.Generic.IEnumerable1[[Microsoft.Practices.EnterpriseLibrary.Logging.Filters.ILogFilter,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35]] filters,
System.Collections.Generic.IEnumerable1[[System.String, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
traceSourceNames,
System.Collections.Generic.IEnumerable1[[Microsoft.Practices.EnterpriseLibrary.Logging.LogSource,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35]] traceSources,
Microsoft.Practices.EnterpriseLibrary.Logging.LogSource
allEventsTraceSource,
Microsoft.Practices.EnterpriseLibrary.Logging.LogSource
notProcessedTraceSource,
Microsoft.Practices.EnterpriseLibrary.Logging.LogSource
errorsTraceSource, System.String defaultCategory, System.Boolean
tracingEnabled, System.Boolean logWarningsWhenNoCategoriesMatch,
System.Boolean revertImpersonation)\r\n Resolving
Microsoft.Practices.EnterpriseLibrary.Logging.LogSource,General\r\n
Resolving parameter \"traceListeners\" of constructor
Microsoft.Practices.EnterpriseLibrary.Logging.LogSource(System.String
name,
System.Collections.Generic.IEnumerable1[[System.Diagnostics.TraceListener,
System, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089]] traceListeners,
System.Diagnostics.SourceLevels level, System.Boolean autoFlush,
Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider
instrumentationProvider)\r\n Resolving
System.Diagnostics.TraceListener,Event Log Trace Listener\r\n"}
I had the same problem and it was due to an error in my configuration file. I referenced trace listeners from my categorySources section which did not exist in my listeners section. I removed the categories and the mappings (i did not use them anyway) and then it worked. I guess you can validate your configuration file in the configuration console and then it will tell you what the problem is.
1 - Make sure you are referencing the correct DLLs
Microsoft.Practices.EnterpriseLibrary.Logging
Microsoft.Practices.EnterpriseLibrary.Common
2 - Make sure your configuration file is in the right location (in the same project or in a references project)
3 - Make sure your configuration file is correct. Editing it with the Enterprise Library Configuration Tool, nothing should be in red. Try expanding all trace listeners, categories, etc. The most common error is that one of the Special Categories is pointing to a non existing Listener.
I had a similar experience with ExceptionHanlder., I switched over to using Unity container directly after playing around with intro material re: logging.
I basically just copied the examples from the Help files and briefly wondered why it wasn't working and errored on Type Resolution; Could not resolve.
The answer was simple enough. I had only "played" with logging prior to switching to Unity container but the examples I was using/copying were using both Logging and Exception Handling injection.
Since I hadn't "played: with Exception Handling in 5.0, there were no entries for this in the configuration file, hence the reason why Unity could not resolve.
Solution: take 5 seconds to add the ExceptionHandling block into the config file using the tools and I was good to go and keep on "playing".
Unity needs the entries for each resolved block in the config file even if they are not Named / customised. This is rediculously obvious but easily overlloked if you are hacking away with example code for learning purposes.
I got this error because a database listener was set with a connection string that didn't exist.
To help diagnose, comment out the listener lines and then add them again one by one.
I got this error when moving the app to another server, and in my case, it was the initializeData field, which sets the path for the log file, was not valid, and it was not able to create the log file at startup.
When i edited and put a valid path for the log to be created, it worked ok.
Hope it helps someone.

Resources