Application crashes on startup - missing Microsoft.VisualBasic.PowerPacks - vb.net

I wrote a simple VB.NET application which works fine on the development machine.
However on another machine, even though the .NET Framework is installed, it crashes on startup with System.InvalidOperationException.
There seems to be a problem with it finding the Visual Basic assemblies.
Here is one of the fails (I replaced sensitive information with three dots):
*** Assembly Binder Log Entry (16/06/2013 # 15:45:12) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Users\....
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = ...
LOG: DisplayName = Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Users/......
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MSystemAdmin.exe
Calling assembly : MSystemAdmin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/.../Desktop/Microsoft.VisualBasic.PowerPacks.Vs.DLL.
LOG: Attempting download of new URL file:///C:/.../Desktop/Microsoft.VisualBasic.PowerPacks.Vs/Microsoft.VisualBasic.PowerPacks.Vs.DLL.
LOG: Attempting download of new URL file:///C:/.../Desktop/Microsoft.VisualBasic.PowerPacks.Vs.EXE.
LOG: Attempting download of new URL file:///C:/.../Desktop/Microsoft.VisualBasic.PowerPacks.Vs/Microsoft.VisualBasic.PowerPacks.Vs.EXE.
LOG: All probing URLs attempted and failed.

It isn't that clear why PowerPacks is missing, the .NET 4 Client Profile could be an issue. There have been multiple versions of PowerPacks around and the version numbering got to be a mess. On my machine, that same version is reported as v2.0.50727, even though it is stored in the GAC as version 10.0
Best thing to do is to go back to your project. Click the "Show All Files" icon on the toolbar in the Solution Explorer window. That now shows the References node. Expand it and select the PowerPacks reference. In the Properties window, change the Copy Local property to True.
Rebuild and your build directory now will have a copy of the DLL. Copy it along with the EXE onto the target machine.

Here is the URL to download Microsoft Visual Basic Power Packs 10.0
http://go.microsoft.com/fwlink/?LinkID=145727&clcid=0x804

Apparently, it seems to be a problem with the "PowerPacks"; these are additional controls to the ones given by default in Visual Studio (in the form design part, under "Toolbox"). If you install the required package on the target computer, everything should be fine.
I had this problem in the past and my recommendation is not relying on these elements: they include nice-to-have features (in my case, it was an elliptic shape) but might be replaced with a bit of work and simpler objects. If you want to sell your program to a more or less wide audience, relying on this might become a problem: this package is not installed by default on virtually any computer and thus you would have to ask your clients to go ahead with the installation. Locating these specific controls is straightforward: on the "Toolbox" they should be listed under "PowerPacks" or similar.
After reading the Hans Passant's comment, I do recall that a .dll file has to be put in the same directory than the executable, but I am under the impression that the PowerPacks package from the provided link has to be installed anyway (at least, on computers not having Visual Studio).

I was upgrading Visual Studio from Visual Studio 2013 to Visual Studio 2015 on a new Windows 10 machine. In doing so I copied my Projects folder from a Windows 7 machine to the same path on the Windows 10 machine.
When I opened a project which used MS.VB.PowerPacks.VS I was informed the file could not be found. I downloaded the newest install for MS.VB.PowerPacks.VS Version 12.0.0.0. Visual Studio 2015 blanked out my form pages which used the PrintForm and informed me:
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualBasic.PowerPacks.VS, Version 10.0.0.0.
I changed the reference to vcersion 12.0.0.0, but it was still not recognized.
My fix: I copied the the C:\Program Files(x86)\Reference Assemblies\Microsoft\VBPowerPacks\v10.0 folder from my Windows 7 machine to my Windows 10 machine, and then removed the v12.0.0.0 reference and added the v10.0.0.0 reference to the program. I then exited the project and opened it again, and all was well, the forms were displayed in their original beauty.

Related

Could not load file or assembly 'log4net, Version=1.2.10.0

I did an application in VS2015 and Crystal Report, I can run it in the development machine (32bits) with no problem, I can load the forms where is CrystalReportViewer and print, all works fine but when I install it in another PC (32bits) and I try to load the form that have the CrystalReportViewer I get: "System.IO.FileLoadException: Could not load file or assembly 'log4net, Version=1.2.10.0 , Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies"
This is all I did:
I confirmed that log4net.dll exist in my debug folder
I saw the version (1.2.13.0) and change it for 1.2.10.0
I tested with a lot of configurations in app.config
I tried this official wiki:
https://wiki.scn.sap.com/wiki/display/BOBJ/Using+Crystal+Reports+for+Visual+Studio+2010+Merge+Modules+(MSM)+to+create+a+Setup+project
(I canĀ“t find any CRRuntime_13_x.msm file)
But the error still showing up
Please can you help me?
I found a quick solution installing CRRuntime_32bit_13_0_16.msi in the new PC, it is not a good solution and I must say that from now I prefer to do the reports with VB Net entirely.

Visual Studio 2015 exception SqlScriptPreprocessSqlVariables when running web publish wizard with update database

Update:
I have reproduced the same Error with a new empty VS2015 WebApplication project.
Added a connectionString to a new empty SQL database
Added a sql-script file to the solution and selected publish... in the publish wizard.
Example of web Publish wizard with included Update script.
I will get the same error building a web deployment package or web deploy .
Original post:
The "SqlScriptPreprocessSqlVariables" task failed unexpectedly. This happens when I use publishing wizard or MSBuild with a profile where the Update Database is selected. On a newly installed machine with only VS2015 Update1 and also on our build server with Team Fondation Server 2015 Build Agent. The same publish profile works in our VS2013 environment.
System.TypeLoadException: Signature of the body and declaration in a method implementation do not match.
Type: 'Microsoft.Web.Publishing.Tasks.SqlScriptPreprocessor.SqlCommandExecuter'.
Assembly: 'Microsoft.Web.Publishing.Tasks, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
at Microsoft.Web.Publishing.Tasks.SqlScriptPreprocessor.SqlScriptPreprocessSqlVariables.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask>d__26.MoveNext()
Here is the same error but from the Build Agent in the new build system. I got the same error runnig XAML build on the new Agent.
##[error]C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Deploy\Microsoft.Web.Publishing.MSDeploy.Common.targets(119,5): Error MSB4018: The "SqlScriptPreprocessSqlVariables" task failed unexpectedly.
##[error]System.TypeLoadException: Signature of the body and declaration in a method implementation do not match. Type: 'Microsoft.Web.Publishing.Tasks.SqlScriptPreprocessor.SqlCommandExecuter'. Assembly: 'Microsoft.Web.Publishing.Tasks, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
##[error] at Microsoft.Web.Publishing.Tasks.SqlScriptPreprocessor.SqlScriptPreprocessSqlVariables.Execute()
##[error] at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
##[error] at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
This is how I fixed the webdeploy packaging problem. This is not a solution I recommend but it works on my machine and on the build server.
Locate the file Microsoft.Web.Publishing.MsDeploy.Common.targets
This is the location on my machine:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Deploy\ Microsoft.Web.Publishing.MsDeploy.Common.targets
On row 117 and forward I commented out the following section.
<!--<SqlScriptPreprocessSqlVariables
UnsupportedKeywords="$(MsdeploySqlUnsupportedCommand)" CheckForUnsupportCommands="$(CheckSqlScriptForUnsupportedCommands)"
TreadSqlScriptUnsupportedCommandsAsWarning="$(TreadSqlScriptUnsupportedCommandsAsWarning)"
SqlScriptFile="%(_DatabasesToPackageForSQL.SourcePath)"
DestinationGroup="%(_DatabasesToPackageForSQL.DestinationGroup)"
ResolveIncludes="$(SqlScriptPreProcessResolveIncludes)"
BatchDelimiter="$(SqlScriptPreProcessBatchDelimiter)"
Condition="$(EnableSqlScriptVariableParameterize) And '%_DatabasesToPackageForSQL.SourcePath)' != '' And Exists('%(_DatabasesToPackageForSQL.SourcePath)') ">
<Output TaskParameter="List" ItemName="_DatabasesToPackage_SqlVariables" />
</SqlScriptPreprocessSqlVariables>-->
I recently faced the same issue and I solved it installing the latest version of "SQL Server Data Tools" and restarting the machine. As #JimAho mentioned, the problem is related to SQL Server Data Tools version installed.
Here you could download it
Don't forget to restart the machine.
Still not quite satisfied with these solutions, I did some research and the least invasive approach I can see is simply registering the assembly in the GAC.
Run VS Command Prompt as Administrator
Hit Windows Start
type "Developer"
Right Click "Developer Command Prompt for VS 2017"
Select Run as Administrator
Run the following command (Replace Enterpise with your installation, e.g. Professional, BuildTools, Community):
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\Microsoft\SQLCommon\130\Microsoft.SqlServer.BatchParser.dll"

Assemblies Failing to load in shadow copied AppDomain

I write the xunit.net test runner for ReSharper, and I've got an issue in the 8.0 release - I'm seeing assemblies failing to load in a shadow copied AppDomain. The same code and test project work fine in the 7.1 release. I don't understand why, though.
When running tests, ReSharper spawns an executable that loads my plugin. I use xunit.net's API to create an AppDomain that has shadow copy enabled. The test project assembly is copied into the shadow copy cache, and starts to load. It copies a dependency into the cache, and loads it - an older version of FakeItEasy, which uses Assembly.LoadFile to load all of the assemblies in the current directory, which is the bin\Debug folder of the test project. So, FakeItEasy loads these assemblies into the Neither load context. Since it's using LoadFile, it bypasses the shadow copy cache, and the files are loaded direct from the bin\Debug folder.
After this, the dependencies of the test project fail to load, resulting in a FileNotFoundException. Fusion binding logs show that it tries to load them, but they don't get copied in the shadow copy cache, and they fail to load. I can't see why. Here's the binding failure:
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/temp/todonancy/TodoNancyTests/bin/Debug/Nancy.Testing.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\temp\todonancy\TodoNancyTests\bin\Debug\Nancy.Testing.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: Nancy.Testing, Version=0.17.1.0, Culture=neutral, PublicKeyToken=null
ERR: Setup failed with hr = 0x80070003.
ERR: Failed to complete setup of assembly (hr = 0x80070003). Probing terminated.
If I disable shadow copy cache, or use a newer version of FakeItEasy that doesn't use LoadFile, it all works. However, I can't blame the older vesion of FakeItEasy - I have users seeing the same errors with other projects and assemblies, all solved by disabling shadow copy cache.
Also, this scenario does work with ReSharper 7.1 - same plugin code and same test project. The only difference is the host application, but I can't see it doing anything different - there are no other assembly resolve event handlers subscribed, for example. The only real difference is that the 7.1 host uses remoting to talk to the Visual Studio application, and the 8.0 uses simple TCP sockets.
Does anyone have any idea why this is failing in the 8.0 version, and yet running with 7.1?
EDIT (07/08/2013):
I've managed to make it fail with a simple test:
[Fact]
public void Thing()
{
Assert.NotNull(Nancy.Bootstrapper.AppDomainAssemblyTypeScanner.Assemblies);
}
Using a copy of the Nancy class added straight into the project (with the referenced ScanMode and AssemblyExtensions classes). The only other content in the project is a reference to xunit.dll and xunit.extensions.dll.
It doesn't fail every time, it's frustratingly intermittent, but I can get it to throw a FileNotFoundException in this call to Assembly.ReflectionOnlyLoadFrom while trying to load the test assembly from the bin\Debug folder.
Here's the fusion log from the exception:
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\JetBrains\ReSharper\v8.0\Bin\JetBrains.ReSharper.TaskRunner.CLR4.MSIL.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: Where-ref bind. Location = C:\Users\Matt\Code\scratch\WeirdXunitFailures\WeirdXunitFailures\bin\Debug\WeirdXunitFailures.dll
LOG: Appbase = file:///C:/Users/Matt/Code/scratch/WeirdXunitFailures/WeirdXunitFailures/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This is an inspection only bind.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Attempting download of new URL file:///C:/Users/Matt/Code/scratch/WeirdXunitFailures/WeirdXunitFailures/bin/Debug/WeirdXunitFailures.dll.
ERR: Failed to complete setup of assembly (hr = 0x80070003). Probing terminated.
Unfortunately, this tells me nothing - the file:// url is valid, and the shadow copy cache contains xunit.dll and WeirdXunitFailures.DLL (the test project). Also, the Modules window in the debugger is showing me that WeitdXunitFailures.dll is already loaded, from the shadow copy cache location.
And again, the really weird thing is that the 7.1 runner works just fine.
EDIT:
In fact, I can get it to fail simply by calling:
[Fact]
public void Thing()
{
Assembly.ReflectionOnlyLoadFrom(#"C:\Users\Matt\Code\scratch\WeirdXunitFailures\WeirdXunitFailures\bin\Debug\xunit.dll");
Assembly.ReflectionOnlyLoadFrom(#"C:\Users\Matt\Code\scratch\WeirdXunitFailures\WeirdXunitFailures\bin\Debug\xunit.extensions.dll");
Assembly.ReflectionOnlyLoadFrom(#"C:\Users\Matt\Code\scratch\WeirdXunitFailures\WeirdXunitFailures\bin\Debug\WeirdXunitFailures.dll");
}
These are the project dll and the two xunit dlls. It's still very intermittent, but seems to be most easily reproduced after a complete rebuild, although it does still occur after several successful runs (so it's not the rebuild that's at fault)
Phew. The problem was (naturally) a subtle change in behaviour in ReSharper 8.
The test runner process API has a method to tell the main ReSharper process (i.e. devenv.exe) the location of the temp folder used for the test run - the shadow copy cache. This is because the test runner process usually can't delete the cache folder because it's still in use. ReSharper will then make several attempts to delete the folder for you, allowing time for the process to die gracefully.
ReSharper 7.1 would delete this folder at the end of a test run, or if the run was aborted.
ReSharper 8 deletes the folder as soon as you call you the method. The nunit test runner tells ReSharper about it at the end of the test run. I was telling it about it at the start. And so ReSharper would happily come along, while my tests were running, and delete whatever it could from the shadow copy cache, making it look like the shadow copy cache was properly broken.
I think I'll be filing a bug :)

Error in registering COM server from bat file lauched from RunOnce

I am currently working on my product installation in Windows XP 64-bit machine. I am trying to register my COM modules as part of installation. I am doing this by adding an entry in 'RunOnce' (registry) key to launch a bat file and registration is done from that bat file.
All my COM dlls are registered correctly but two of the COM servers (.exe) showing error that it failed to load one of its dependency dll. But the same dll is statically linked with another COM server and this server registered successfully !
And surprisingly running the same bat file directly(double clicking on it) doesn't generate any errors and its works fine for all assemblies!. I have checked this in couple of my test machines only of the machines showing this behavior. Unfortunately that't the customer tool machine.
Its not dependency dll not available issue. Because after registering all files by directly running the bat file, I could reproduce this again by adding a key in RunOnce manually and restarting the machine.
Additional info, I am accessing this machine remotely via logmein.
Exact error message: "This application has failed to start because XXX.dll was not found. Re-installing the application may fix this problem".
This XXX.dll is not available in the same path but its in another folder and its path is available in path variable.
bat file content is;
"C:\WINDOWS\system32\regsvr32.exe" RemoteControlHandler.dll
"C:\WINDOWS\system32\regsvr32.exe" ProcPgmHandler.dll
"C:\WINDOWS\system32\regsvr32.exe" GEM300Handler.dll
"C:\WINDOWS\system32\regsvr32.exe" ICEScreenAdapter.ocx
HIB.exe /regserver //Throws error
JobManager.exe /regserver
Cim300Adapter.exe /regserver
GemEquipmentCtrl.exe /regserver //Throws error
Hope this information is enough for experts, feel free to ask if you need any additional information.
Nixon

How can I fix these errors from Visual Studio Express 2012 for Windows Phone?

I am in Visual Studio Express 2012 for Windows Phone, and have followed the MiniBrowser Tutorial located at the following link:
http://msdn.microsoft.com/en-US/library/windowsphone/develop/ff402526(v=vs.105).aspx
After following all the instructions, once I get to "Run Your App" portion of the instructions, under step 1, Build, the following errors are generated:
Error 1 The name "LocalizedStrings" does not exist in the namespace "clr-namespace:MiniBrowser". c:\users\avery_000\documents\visual studio 2012\Projects\MiniBrowser\MiniBrowser\App.xaml 1 1 MiniBrowser
Error 2 The name "LocalizedStrings" does not exist in the namespace "clr-namespace:MiniBrowser". c:\users\avery_000\documents\visual studio 2012\Projects\MiniBrowser\MiniBrowser\App.xaml 10 9 MiniBrowser
Error 3 The build stopped unexpectedly because of an internal failure.
Microsoft.Build.Exceptions.BuildAbortedException: Build was canceled. Failed to successfully launch or connect to a child MSBuild.exe process. Verify that the MSBuild.exe "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" launches successfully, and that it is loading the same microsoft.build.dll that the launching process loaded. If the location seems incorrect, try specifying the correct location in the BuildParameters object, or with the MSBUILD_EXE_PATH environment variable.
at Microsoft.Build.BackEnd.NodeProviderOutOfProc.CreateNode(Int32 nodeId, INodePacketFactory factory, NodeConfiguration configuration)
at Microsoft.Build.BackEnd.NodeManager.AttemptCreateNode(INodeProvider nodeProvider, NodeConfiguration nodeConfiguration)
at Microsoft.Build.BackEnd.NodeManager.CreateNode(NodeConfiguration configuration, NodeAffinity nodeAffinity)
at Microsoft.Build.Execution.BuildManager.PerformSchedulingActions(IEnumerable`1 responses)
at Microsoft.Build.Execution.BuildManager.HandleNewRequest(Int32 node, BuildRequestBlocker blocker)
at Microsoft.Build.Execution.BuildManager.IssueRequestToScheduler(BuildSubmission submission, Boolean allowMainThreadBuild, BuildRequestBlocker blocker) c:\users\avery_000\documents\visual studio 2012\Projects\MiniBrowser\MiniBrowser\MiniBrowser.csproj MiniBrowser
What do these errors mean?
Looks like when Visual Studio Express 2012 for Windows Phone installed on my computer, it put the project folder onto the same hard drive as the application. For some reason, the solution in order to get this to compile, was to recreate the project on a different hard drive, and work from there.
Thanks everyone for your assistance!