![](/img/trans.png)
[英]Microsoft.VisualStudio.Web.Host.exe locking 32-bit processes with Visual Studio 2012/WIn7
[英]MVC Web Service returns - Microsoft SharePoint is not supported in 32-bit process
我正在尝试实现DocX,以使用Web服务替换Sharepoint中文档库中文档的信息。 我遇到了困难,因为当我运行项目并尝试将信息发送到api地址时,出现以下错误
Microsoft SharePoint is not supported in 32-bit process. Please verify that you are running in a 64-bit executable.
调试时,代码在以下行中中断
using (SPSite site = new SPSite(siteurl))
我发现我需要以64位模式运行该项目,但是如果选择该选项,则该项目将无法运行。 我还发现,无法选中“首选32位”选项,但该选项被禁用且未选中,最后在IIS应用程序池高级设置中,我需要将“启用32位应用程序”选项变为true,但它没有执行任何操作。
较早的版本都没有为我工作,我想寻求解决此问题的帮助。
我正在使用Sharepoint 2013,Visual Studio 2012和MVC 4。
编辑-
API功能
public class DocumentController : ApiController
{
public DocModel Get(string docId, string docName, string docLibrary, string newDocLibrary)
{
DocModel document = new DocModel();
try
{
string siteurl = "http://win-n1ni65gppp2/";
using (SPSite site = new SPSite(siteurl))
{
using (SPWeb web = site.OpenWeb())
{}
}
catch (Exception ex)
{
document.Message = ex.ToString() + "Perdistes";
Console.Write(ex);
}
return document;
}
}
应用程序在任何CPU上时的异常消息
System.PlatformNotSupportedException:32位进程中不支持Microsoft SharePoint。 请确认您正在64位可执行文件中运行。 在Microsoft.SharePoint.Administration.SPConfigurationDatabase.get_RegistryConnectionString()在Microsoft.SharePoint.Administration.SPConfigurationDatabase.get_Local()在Microsoft.SharePoint.Administration.SPConfigurationDatabase.get_RegistryConnectionString()在Microsoft.SharePoint.Administration.SPFarm.FindLocal(SPFarm&farm, Microsoft.SharePoint.Administration.SPFarm.get_Local()(Microsoft.SharePoint.SPSite..ctor(String requestUrl)上的Boolean&isJoined)SPDocumentAPI.Controllers.DocumentController.Get(String docId,String docName,String docLibrary,String newDocLibrary)
在应用程序属性中的x64平台下构建应用程序时出现错误消息
无法加载文件或程序集“ SPDocumentAPI”或其依赖项之一。 试图加载格式错误的程序。
堆栈跟踪
[BadImageFormatException:无法加载文件或程序集'SPDocumentAPI'或其依赖项之一。 试图以错误的格式加载程序。] System.Reflection.RuntimeAssembly._nLoad(AssemblyName文件名,字符串codeBase,证据AssemblySecurity,RuntimeAssembly locationHint,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,布尔throwOnFileNotFound,布尔值用于Introspection,布尔值抑制) 0 System.Reflection.RuntimeAssembly.nLoad(AssemblyName文件名,字符串codeBase,证据assemblySecurity,RuntimeAssembly reqAssembly,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,布尔throwOnFileNotFound,布尔值用于自省,布尔抑制安全性检查)+152 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecuri ty,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,用于自省的布尔值)+77 System.Reflection.RuntimeAssembly.InternalLoad(字符串assemblyString,证据assemblySecurity,StackCrawlMark&stackMark,用于自省的布尔值)+16 System.Reflection.Assembly.Load(字符串assemblyString)+28 Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)+38
[ConfigurationErrorsException:无法加载文件或程序集'SPDocumentAPI'或其依赖项之一。 试图加载格式不正确的程序。] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串assemblyName,布尔型StarDirective)+752 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()+218 System.Web.Configuration .CompilationSection.LoadAssembly(AssemblyInfo ai)+130 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)+170 System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()+91 System.Web.Compilation.BuildManager.CallPrePath ,Boolean&isRefAssemblyLoaded)+285 System.Web.Compilation.BuildManager.ExecutePreAppStart()+153 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager,IApplicationHost appHost,IConfigMapPathFactory configMapPathFactory,HostingEnvironmentParameters,hostingParameters,PolicyLevel policyLevel,Exception appDomain)
[HttpException(0x80004005):无法加载文件或程序集'SPDocumentAPI'或其依赖项之一。 试图加载格式错误的程序。] System.Web.HttpRuntime.FirstRequestInit(HttpContext上下文)+9915300 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext上下文)+101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr ,HttpContext上下文)+254
很好,该项目正在IIS Express上运行,并且IIS Express似乎无法在Visual Studio 2012上编译64位应用程序。
我发现此链接说明了如何向注册表添加一些更改。
最后,只需在命令提示符下运行以下代码,然后重新启动服务器即可。
reg add HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\WebProjects /v Use64BitIISExpress /t REG_DWORD /d 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.