C# Could not load file or assembly 'Microsoft.SharePoint.Library' - c#

I am developing on a 64bit version of Windows 7, running MOSS (SharePoint), this is my dev machine.
Now when I deploy my web service app to a test server Windows 2003 32bit (no Sharepoint installed) I get this error.
Could not load file or assembly 'Microsoft.SharePoint.Library, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified
The DLL has clearly been copied to the bin directory (Microsoft.Sharepoint.dll).
Any ideas?

If you are using sharepoint dll's it will only work on a machine with sharepoint installed.
Even if you managed to hack it and get it to work, you would probably be breaking a license agreement.

There is a way to load Sharepoint libraries in a development console with windows XP, Vista or Seven.
See here: http://fernandof.wordpress.com/2008/02/11/how-to-install-the-sharepoint-2007-vs-2005-extensions-on-a-workstation/
[O]pen the regedit and create the following keys and the string value:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0]
"Sharepoint"="Installed"
That’s it! You have fooled the installer into running on a
workstation. Easy. I also recommend adding the core SharePoint
assemblies into the [GAC] using gacutil. Those assemblies can be found
by default in any [SharePoint] machine under the folder: C:\Program
Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI.

This is almost certainly a dependency issue. The DLL is dependent on another DLL which isn't in the GAC or on the probing path. The two tools you need to figure this out are FUSLOGVW.EXE and Process Monitor
Fusion Log viewer will allow you to look at assembly bind successes and failures as your application loads. It's part of the Windows SDK.
http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx
FUSLOGVW needs admin privs to run correctly.
If that doesn't work another tactic is to use Process monitor to look at which files aren't getting loaded and which folders are being searched.
http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
However. Without SharePoint installed I wouldn't expect this to work.
Ade

From MSDN:
"The CI build environment for the Training Management application does not perform any tests that require a live instance of SharePoint. All the unit tests use mocks that replace the actual SharePoint instance and services. Building the code and running the unit tests only requires that the following SharePoint assemblies are installed on the CI build server:
Microsoft.SharePoint
Microsoft.SharePoint.Security
Microsoft.SharePoint.WorkflowActions
Supporting referenced assemblies"
http://msdn.microsoft.com/en-us/library/ff647619.aspx

Don't mix 64-bit and 32-bit for dev / testing / production. This will never work reliably if at all.

Well what about other dlls referenced by the Sharepoint dll? With long dependency chains it can be quite difficult to diagnose these sort of problems. In such situations I find the fusion log viewer extremely useful. It is a part of framework SDK - open the SDK Command prompt and type fuslogvw. It is pretty obvious from there

Related

Desktop applicaton not opening after installation in client system

I am currently working with visual studio 2017 with 4.6.1 .net framework. I created setup file for my desktop application the setup installs and runs perfectly in my system. The issue is that the setup installs successfully in other computers but the application not getting opened.
edit
Downloaded .net framework in client system but still same issue occurs.
edit 2
I ran a dependency scan using Dependency walker. It said there were a bunch of files the system could not find - error opening file. The system cannot find the files specified.
API-MS-WIN-APPMODEL-RUNTIME-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL
API-MS-WIN-SHCORE-SCALING-L1-1-1.DLL
DCOMP.DLL
IESHIMS.DLL
Also, there was an error with modules with an x86 type found - including the setup.exe - but I am unaware how this happened. I have selected 64 wherever I saw the option listed. Please find the screenshot. If this is indeed the issue, how do I solve this?
Application Launch Problems: Here is a short version: WPF application crashes when I launch. Chattier version. Nice one from Martin Prikryl: Application does not work when installed with Inno Setup
Logs: Always check all event logs, application logs and MSI logs - if available. Just to mention it. Maybe try to attach debugger for testing as described here - provided the application gets off the ground at all. Then step through code.
The Usual Culprits: You probably just lack a runtime (example), have a bitness problem (32/64-bit) or insufficient permissions / privileges, or configuration errors (ini, xml, registry, etc...).
To summarize - torpedos, full spread below - nothing too dumb not to mention :-):
Missing Runtimes: First, always check for missing runtimes. For example: .Net, .Net Core, Java, Silverlight,
Direct X (used even for applications now), VC++ Runtime, MS-XML (legacy), etc.... Remember that they come in different versions and some can not co-exist on the box whilst others
can run side-by-side.
Error Code: Looking up error codes and exception messages.
"The Magic Number Database" - online lookup.
Checking Error Codes - several tools and approaches.
Debugging Tools: Some information on debugging tools.
Tools to debug dependency issues - ProcMon.exe, VS, Dependency Walker, etc...
COM dependency errors
Essential service debugging tools:
Event Viewer, Task Manager, Services.msc
Process Explorer, NET command, SC.exe
Windows Services Frequently Asked Questions (FAQ)
ProcMon.exe: The tool of the trade. The one-size-fits-all
tool. The bee's knees, the topper-most, the quantum leap, the cat's
pajamas (yes, it is a Top Gear Hamster allusion). It can be a challenge to use it effectively, but it is the
best general-purpose debugging tool that is free.
Quick, Rudimentary Sample
Hanselman's longer video sample
Other Ideas:
Configuration Settings?
Dev-box sins: Hard coded references? Test Servers / UAT links?
Manifests, INI files and XMLfiles?
Registry settings? HKLM / HKCU
Connection strings. See Authentication & Authorization section below as well.
Platform & Bitness? (ARM, Intel 32 / 64, etc...).
Very common to read from wrong registry hive (the classic time waster):
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\MyApp\MySettings (32-bit)
HKEY_LOCAL_MACHINE\SOFTWARE\MyApp\MySettings (64-bit)
Prerequisites & Dependencies?
On the topic of dependency scanning and debugging.
Dependency Walker: Types of dependencies.
Does Fuslogvw.exe tell you anything? (.NET assembly binding failures for a .NET application). How the Runtime Locates Assemblies
Quick check: Visual Studio modules view
Missing / Broken Registration (indirect dependencies)
Missing COM, COM Interop (regasm.exe), registrationless COM (manifest based)
Calling a .NET Component from a COM Component
Calling COM Components from .NET Clients
Broken Side-By-Side Win32 Assembly Manifest (obscure, can be caused by sloppy corporate application repackaging, may strike seemingly random PCs)
GAC installation?
Two GACs exist.
GAC / WinSxS Commit Issues: GAC / WinSXS files don't get installed into the GAC until the commit phase which is after StartServices.
Permissions & Privilege? - local - ACL permissions and NT privileges?
ProcMon.exe
Resolving Permission Denied:
System.UnauthorizedAccessException while running .exe under program files
WiX after installation my exe file doesn't work by double click, only run as administrator work
Authentication / Authorization - network related
Local user, domain user, Active Directory: group membership, group policy, etc...
Launching User: User profile issues? Maybe try with another user logged on where it fails?
Authentication Mode: Windows Authentication. SQL Server Authentication, etc...
General Network & Proxy issues? (proxies, WINS, DNS and all the complexities involved in networking. UNC paths reachable?)
Licensing? (conceivably related to hardware dongles and drivers)
Security software interference? (software / hardware firewall, anti-virus, encryption tools and suites, etc...)
OS version or edition? (Windows 7 problems)
Localization? Non-English systems?
Drivers?
Hardware?
Encoding?
System corruption? (wrong time, disk errors, file and path names are too long, disk full, "wrong something")
Target Machine Nature? Virtuals? SOE? Are the target machines real machines? Test machines?
Locking / Blocking / In-Use files and registry keys?
Malware? Can cause practically anything in terms of problems.
Links:
WiX Toolset PermissionEx Problem - App Does Not Run After Installation
EXE file is not working
make sure that the 4.6.1 .net framework is installed on the client system.Because the application requires .net frame work installed on the computer
To successfully deploy an application, you must also deploy all components that are referenced by the application.View the Deployment Process
Users might need administrative permissions or similar user permissions on the computer to install bootstrapped components. For ClickOnce applications, this means that the user might need administrative permissions to install the application regardless of the security level specified by the application. After the application is installed, the user can run the application without administrative permissions.
I am assuming you and your client are running install and application run as Administrator.
Possible root cause:
System prerequisite is not meet, you should check all dependencies is ready on the target client system, or add the prerequisite to your installation guide
Privilege issues, you might copy files or change registry locally with administrator rights, but the client is not. If so, you need change files to "C:\Users{username}\AppData\Roaming" or install with administrator privilege on the client system.
In such a situation, app possibly crashed in client system:
Check your application log if any errors
Check windows Log if any errors
Dump system info using WinDbg.exe and debug it
I also faced that kind of problem before.
Just try to install another location not inside the program file of C:\ Drive. You may choose different drive or you may install in C drive also but not inside the program files.

Could not load file or assembly - not working on asp, works on desktop

While using a native dll dependency on a asp.net web project and debugging in VS2015 with IIS express I'm getting the dreaded:
Could not load file or assembly 'XXX.DLL' or one of its dependencies. The specified module could not be found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'XXX.DLL' or one of its dependencies. The specified module could not be found.
HOWEVER the same dependency works fine in a simple forms app on the same machine - hence I assume all the dependencies and co-dependencies are present
maybe you have some clues, how can this be?
What I already tried:
putting all the potential dependencies in the web project output folder
putting all the potential dependencies in the /system32/ path
putting all the potential dependencies in the /system32/inetsrv and /sysWOW64/inetsrv
installing c++ redistributables (2010, 2012, 2013)
I 'unblocked' the dlls as they "came from another computer" (CASpol)
dependency walker did not give any clear results
process monitor did not give any clear results
some details:
VS2015 Community, running on an Azure VM with Windows Server 2012 (test system), clean install
the app uses CGAL and BOOST libraries (c++).
'Dependency tree' is as follows: C# wrapper references a CLR C++ project which in turn references the native C++ (only this one uses CGAL/Boost);
The C# wrapper is then used in the forms app (works) or the asp.net web app (doesn't work);
Putting Cgal dlls (around 6 files) into the bin output folder was enough to run the forms app.
PS: of course on my 2 dev machines (Win 7, Win 10) the asp.net project works swimmingly - but these contain dedicated installs of the huge c++ references.
PPS: I currently really prefer to use iis express due to external reasons. I have to simulate deploying the app on a clean-ish Win10 laptop, in a dev environment, with minimal external installations
PPPS it seems the win10 dev machine isn't working after all - edit: this was the key clue, see my answer below and Ho do I reference native files in IIS express?
I'm a bit stuck right now, thanks.
Solution: on Win 10 I copied the dll output (\bin folder) into the Program Files (x86)\IIS Express folder (as I am using the 32-bit version).
Apparently, this wasn't needed on Win7 - I will have to investigate why
I found this solution in:
Ho do I reference native files in IIS express?
EDIT: another, more elegant (?) solution is to disable shadow-copying in web.config as in http://faithlife.codes/blog/2013/05/using-native-dlls-from-asp-net-apps/
"The simplest solution I’ve found is to turn off shadow copying, which causes the DLLs to be loaded directly from the bin directory.(...) Just add a hostingEnvironment element to your web.config:"
<configuration>
...
<system.web>
...
<hostingEnvironment shadowCopyBinAssemblies="false" />

Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. Error on Windows Server 2012

I have a multi-project solution (C#) that I am trying to deploy to one of our test servers. All the projects are being built for x64, with the 'Prefer 32 bit' disabled where applicable.
Some of the projects reference a SQLite dll set that uses the SQLite Encryption Extension (not managed by nuget). When I build and install the solution on my local dev machine, the application and windows service are able to function properly, no problems.
When I try to install the same package on one of our test servers, running 64-bit Windows Server 2012, I get the "Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found." whenever I try to communicate with the SQLite database. I have triple checked that all the appropriate DLLs are in the program folder after installation.
In my VS solution, I have tried creating the x86/x64 folders, setting Copy to Always, but to no avail. I have also copied the DLLs from my local install folder into the server folder just to see if something got messed up along the way.
Could it be a permissions issue? I'm an elevated user but not a full admin on the server, whereas I'm a full admin on my machine. I've tried manually modifying the permissions on the program folder to see if that was an issue, but had no luck with that either.
So to summarize, the project is being explicitly built for x64, it has the right DLLs in the right folders, and it works on a local install. I'm at a loss as to why it won't work on the server install. I've looked through countless threads on StackOverflow, MSDN, and SQLite's website, all usually suggesting the x86/x64 folders, but that hasn't been working for me. I'm hoping someone can help me out here.
Thanks!
Was actually able to figure it out after a bit more debugging. The Visual C++ runtime that was installed on the server wasn't the right version. I added the Merge Module to the installer for the version my project was expecting, reinstalled the app on the server, and now it's working beautifully.
For those who have this issue, look for the right version of the VC++ runtime in C:\Program Files(x86)\Common Files\Merge Modules. If you don't know what version you need, use something like dependency walker on the machine that is throwing the error. Mine told me I was missing VC140, so that's the module I copied into my project and added to the installer.

Could not load file or assembly CrystalDecisions.ReportAppServer.ClientDoc

I've looked at similar questions on SO, but nothing quite matches my issue as far as I can tell.
The exception message:
Could not load file or assembly 'CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified.
The file is in my GAC. I am developing on a 32 bit machine (Windows 7) running VS2010, everything is .NET4. The target hosting machine is 64-bit Win 2008 R2. My local machine has the CR installation for VS2010; the hosting machine has the 64-bit runtimes for VS2010. I am compiling all my code in "Any CPU" mode for this web application.
It is blowing my mind that it cannot find the file in the GAC. This is an IIS application; is there some sort of permissions issue? I would think IIS would have access to the GAC.
Some suggestions of what to do would be appreciated.
It turns out the answer was ridiculously simple, but mystifying as to why it was necessary.
In the IIS Manager on the server, I set the application pool for my web application to not allow 32-bit assemblies.
It seems it assumes, on a 64-bit system, that you must want the 32 bit assembly. Bizarre.
1) Change your .net profile from Client profile to to .Net Framework 4.0
http://msdn.microsoft.com/en-us/library/bb398202.aspx
2) Check your Embed Interop Types flag
http://weblogs.asp.net/cazzu/archive/2011/03/11/check-your-embed-interop-types-flag-when-doing-visual-studio-extensibility-work.aspx
Regarding the 64-bit system wanting 32-bit support. I don't find it so bizarre:
Although deployed to a 64-bit system, this doesn't mean all the referenced assemblies are necessarily 64-bit Crystal Reports assemblies. Further to that, the Crystal Reports assemblies are largely just wrappers to a collection of legacy DLLs upon which they are based. Many 32-bit DLLs are required by the primarily referenced assembly. The error message "can not load the assembly" involves these DLLs as well. To see visually what those are, go to www.dependencywalker.com and run 'Depends' on the assembly in question, directly on that IIS server.
You simply need to install Crystal Report Report Run Time downloads on Deployment Server. If problem still appears, then place check asp_client folder in your project main folder.

ASP.NET web application: Unable to read DLL

I have an ASP.NET application, which has two references added: MapServer and GDAL. These two DLL's uses a bunch of other DLL's, and all of them are in my applications /bin directory.
When I run the application on my own PC in Visual Studio 2010 it runs fine. When I upload it to my Windows 2008 server with IIS it throws this exception:
Could not load file or assembly 'gdal_csharp' or one of its dependencies.
An attempt was made to load a program with an incorrect format.
When running the application through Visual Studio on the server it runs fine.
I've even tried adding the /bin directory to the PATH enviroment variable, and restarting the server. No luck though.
My guess is that the DLL is a 32-bit only DLL that you are trying to run in a x64-environment. Can you try to set the app-pool to 32-bit only?
Update: a simple instruction is here: http://help.webcontrolcenter.com/KB/a1114/how-to-enable-a-32-bit-application-pool-in-iis7-dedicatedvps.aspx
You need to register the dll at GAC: http://en.wikipedia.org/wiki/Global_Assembly_Cache
As already mentioned you may be missing something from the GAC.
To see whats happening you could try turning on Fusion Logging, this will enable you to view all of the assembly load failures.
Back to Basics: Using Fusion Log Viewer to Debug Obscure Loader Errors

Categories

Resources