I've been developing for SharePoint for roughly 2 weeks and I keep running across the same problem. How do I successfully access SPWeb object? Here's my issue:
If I try to access SPWeb (SPWeb site = SPContext.Current.Web) I get an error message: "Microsoft SharePoint is not supported in 32-bit process. Please verify that you are running in a 64-bit executable."
Ok, no problem. So, I change my Project AND my Web Project to x64 under Properties -> Build -> Platform target.
Now when I run the application I get the following error: "Could not load file or assembly 'xxxWeb' or one of its dependencies. An attempt was made to load a program with an incorrect format."
I've tried many things and this is a right-out-of-the-box solution. What am I doing wrong?
EDIT: Image of error information (may need to zoom in):
Related
I have created a Windows Service using ASP.Net Core 3.x and C#. I started with the new Windows Service template when I built the project. When I run it from my development environment or from a console window it runs fine. When I install it as a Windows Service and attempt to start the service I get an
"Error 5: Access is denied." error.
I tried numerous things which I will outline below to eliminate the error but nothing seemed to work so I downloaded the sample app provided by Microsoft, at sample
Same result...when I run the sample app from within Visual Studio it runs fine, when running as a service I get the Access Denied error.
I am running all of this on my local machine, which I am an admin on.
I originally tried to run it using the default Local System account; got the Access Denied error.
I changed the Log On As to my domain account, the same one I use to log into my local machine which is an admin on this machine; got the same Access Denied error.
My account has the privilege set to run as a service.
The Event Viewer just shows the one message which says "Access Denied", no other messages are created.
I believe the Access Denied error is occurring before the C# code is even executed. What makes me believe this is that I added one line to the very top of the Program.Main.... File.WriteAllText("C:\\temp\\ws.log", $"Test of Worker Service # {DateTime.Now}. Content Root Path: {AppContext.BaseDirectory}");. My account has full access to the temp folder. This file gets created when I run the app from Visual Studio but it does not get created when I run the app as a service.
I have read numerous web sites, include this one and this one. No luck, everything I tried from these sites still produce the Access Denied error.
I have run out of ideas and am hoping someone here can provide me the answer. Thanks!
I found the solution and believe me I feel really stupid!!!
When I installed it as a service I only put the path in "binPath".
sc create WindowsService1 binPath="C:\temp".
Once I actually added the executable to the binPath parameter everything worked.
Changed it to sc create WindowsService1 binPath="C:\temp\WindowsService.exe" and it worked.
I know it is an Id10t error but Microsoft should really provide better messaging for the "sc" command. A message like "Cannot find file specified in the binPath parameter" would have been really helpful. Would have saved me about 6 hours of work.
Thanks everyone for reviewing and replying to this question.
I'm trying to implement Brother b-Pac printing library for label printing devices into my web application. I need to create/load the label template on server and print from the client's machine over a browser.
My code is totally working on my development environment. It only occurs on the published version. It's an access denied error thrown when the COM object got called by the app. I suspect there's an inner exception I couldn't reach.
The event got logged as follows:
Faulting application name: w3wp.exe, version: 8.5.9600.16384
Faulting module name: bpac.dll, version: 3.2.0.20
Exception code: 0xc0000005
Fault offset: 0x0010beea
Faulting application path: C:\Windows\SysWOW64\inetsrv\w3wp.exe
Faulting module path: C:\Program Files (x86)\Common Files\Brother\b-PAC\bpac.dll
I also used DebugDiag on the dump file and here's the report. Though it says here debugger couldn't locate debug symbols for bpac.dll, so it may be incomplete (If it may help, I'd like to know where and how to get symbols for a 3rd party DLL)
Application is a multilayer ASP.NET MVC app targeting the .NET Framework 4.6.1, running on a virtual machine with Windows Server 2012 R2 (x64) and IIS 8. (If it matters the project is derived from this template)
I searched about the issue and tried the following solutions:
Give read/write permissions of wwwroot and DLL's own folder to the IIS APPPOOL/user of the faulting w3wp.exe.
Give same permissions to IIS_IUSRS, NETWORK, NETWORK SERVICE users.
Impersonate Administrator user.
Uninstall/install 32bit/64bit versions of the b-Pac SDK.
Change bitness of my ASP app and all projects within to x86/x64.
Enable 32bit on the Application Pool.
Patch the Windows for July 2018 update issue
Setting Anonymous Authentication, App pool identity etc. all to the default pool user.
Loading the DLL dynamically. (not sure if I did this correctly though)
The COM object I'm trying to initialize is bpac.Document. Interface is IDocument and the concrete class is DocumentClass. I wasn't familiar with any of these concepts before. And I'm still struggling to understand but I tried all of these following lines for initialization:
Document label = new Document();
DocumentClass label = new DocumentClass(); //embed interop types: false
IDocument label = new Document();
After that, I'm using label object to open a template and etc. But as soon as the application hits any of the above lines it crashes the server and restarts the app.
Incidentally, the DLL file is referenced as a COM library in my WebService (App) project (not in the Web project). So it doesn't get copied on bin folder (I guess that's the correct behaviour?). Tried changing isolation/interop settings but I'm not sure if those are related to the issue at hand.
I read things about Registering COM objects into GAC and Marshalling for Remote Access but I couldn't grasp how to apply these properly. Thing is, the official documentation doesn't say anything about this. And there isn't a single example for using b-Pac library on a modern C# ASP.NET setting (only a little on VB ~eww~).
I'm a developer, not a DBA so I'm not too confident with tweaking the server's settings. But for this issue alone, I modified too many things too many times.
So, the problem was about the app id permissions all along. I changed the Application Pool's identity to LocalSystem and now it works as expected.
Still, I'm not sure what kind of security flaws this change would cause in the future. I posted this link to the vendor's technical staff. But they didn't give me an answer yet.
When publishing project to windows server 2003 (old test machine) I get following error when trying to call open cv functions.
Additional information: The type initializer for 'Emgu.CV.CvInvoke' threw an exception.Unable to load DLL 'cvextern': The specified procedure could not be found. (Exception from HRESULT: 0x8007007F)
I am using EmguCV 3.4.1 version with uploaded libraries:
vcruntime140.dll
opencv_ffmpeg341.dll
msvcp140.dll
cvextern.dll
concrt140.dll
To the Emgu package nothing extra (dll's) were added and on developer machine I could develop the application.
I keep wondering whether additional native dll's should be added. I downloaded binaries for 3.4.1 version. The files go like that:
opencv_core249.dll
opencv_highgui249.dll
Those two above where in 3.4.1 package. When i copied them to program directory it didn't help either.
What's more I have no idea how to track down the problem.
Process monitor doesn't show that the process is looking for something that cannot be loaded.
In the inner exception I am given only this exception: Unable to load DLL 'cvextern': The specified procedure could not be found. (Exception from HRESULT: 0x8007007F)
I had to install "Desktop Experience" feature on my server. Because server 2003 doesn't seem to have it, I had to move it to another server 2008 host.
This question is related to my previous question.
I need to publish a C# application (that has been set up in IIS 6.0 and built in VS2010) to a desktop with win7.
I have set up IIS on my desktop well. Now I can install the application on my laptop by accessing the URL
http://myDesktopName.domain.com/MyApp
pointing to a physical location in desktop
e:\myPath\myApp\myAppService.svc
When I publish a new version of the web service, the application should get updated when I open it.
But, it gave me an error:
**the filename,directory name, or volume label syntax is incorrect**
After searching online, I found this error is normally caused by some unacccepted chars in the link. Here is the code that the msi (MS installer) needs to access and get the new version of the application.
System.Diagnostics.Process.Start("msiexec", "/favmuso \"" + myurl + "\"");
here,
myurl is http://myDesktopName.domain.com/MyApp/MyAppSetup.msi
Here, http://myDesktopName/MyApp/ is the virtual directory set in IIS 6.0 on my desktop. I can access and download it from IE in my laptop without any problems.
But, when the application notified me that a new version is available for updating the old one, I clicked the pop-up ballon on the application icon and then I got the error:
Error 123. The filename, directory name, or volume label syntax is incorrect.
If I try to access it from the C# code, I got the same error.
Then, I did a test by running
msiexec **/favmuso** http://myDesktopName.domain.com/MyApp/MyAppSetup.msi /Lv mapp_msi.log
In the log file, i found :
MSI (s) (80:DC) [18:04:33:089]: SECREPAIR: Failed to open the
file:http://myDesktopName.domain.com/mypath/\myAppSdetup (10).msi for computing its hash. Error:123
Error 123. The filename, directory name, or volume label syntax is incorrect.
Why my applcation setup file name was changed to
\myAppSdetup (10).msi
The "/favmuso" options can be found at
https://technet.microsoft.com/en-gb/library/cc759262%28v=ws.10%29.aspx#BKMK_Install
Any help would be appreciated.
thanks
So I noticed that you've asked this question elsewhere, and everyone was focused on the /favmuso piece of it.
I've been recently exeriencing this issue when trying to repair MSIs with a URL source when the original application was installed by SCCM 2012.
The workaround I found was to add a registry value at HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer. The value below causes the MSI to skip the problematic portion of the repair and move on.
Name: SecureRepairPolicy
Type: REG_DWORD
Value: 1
To be a bit safer, you look into setting the registry value to 2 and using a whitelist as described in this Microsoft article: https://support.microsoft.com/en-us/kb/2918614. (Ctrl+F "Steps to opt-out the affected programs".)
I get the following error when trying to start the ASP.NET State Service:
Windows could not start the ASP.NET State Service service on Local Computer.
Error 2: The system cannot find the file specified.
Everything I found on google told me to go to the %windir%\Microsoft.NET\Framework\v1.1.4322 folder at the command prompt, and then type the following command: aspnet_regiis.exe -ir
which I did and didn't solve the problem. The path to the executable in my case is 2.0: C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_state.exe.
So I tried the same comand on the v2 folder and I get the error:
"An attempt was made to load a program with an incorrect format".
thanks in advace for any help
As stated here, it's trying to load the 32-bit version while you need the 64-bit. If this is applicable, open RegEdit (own risk and so on) and change HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\ImagePath
from %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_state.exe to %SystemRoot%\Microsoft.NET\Framework64\v2.0.50727\aspnet_state.exe.
You not need reinstall this service.
Just find in services "ASP.NET State Server" and start it.
Also you can set up to start this service automaticaly in preferences.