简体   繁体   English

MVC Web服务返回-32位过程中不支持Microsoft SharePoint

[英]MVC Web Service returns - Microsoft SharePoint is not supported in 32-bit process

I am Trying to implement DocX to replace information from documents on a Document Library in Sharepoint using a web service. 我正在尝试实现DocX,以使用Web服务替换Sharepoint中文档库中文档的信息。 I am having difficulties because when I run my project and try to send information to the api address I get the following error 我遇到了困难,因为当我运行项目并尝试将信息发送到api地址时,出现以下错误

Microsoft SharePoint is not supported in 32-bit process. Please verify that you are running in a 64-bit executable. 

While debugging the code breaks on the following line 调试时,代码在以下行中中断

 using (SPSite site = new SPSite(siteurl))

I have found that I need to run the project on 64bit mode but if I choose that option the project does not run. 我发现我需要以64位模式运行该项目,但是如果选择该选项,则该项目将无法运行。 I also found that the option Prefer 32bit cannot be checked but that option is disabled and not checked and finally in the IIS application Pool advance settings I need to turn into true the option Enable 32bit applications but it did not do anything. 我还发现,无法选中“首选32位”选项,但该选项被禁用且未选中,最后在IIS应用程序池高级设置中,我需要将“启用32位应用程序”选项变为true,但它没有执行任何操作。

None of the earlier have worked for me, I would like to ask for some help on solving this issue. 较早的版本都没有为我工作,我想寻求解决此问题的帮助。

I am working on Sharepoint 2013, Visual Studio 2012 and MVC 4. 我正在使用Sharepoint 2013,Visual Studio 2012和MVC 4。

EDIT - 编辑-

API Function 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;
    }

}

Exception Message while application is on Any CPU 应用程序在任何CPU上时的异常消息

System.PlatformNotSupportedException: Microsoft SharePoint is not supported in 32-bit process. System.PlatformNotSupportedException:32位进程中不支持Microsoft SharePoint。 Please verify that you are running in a 64-bit executable. 请确认您正在64位可执行文件中运行。 at Microsoft.SharePoint.Utilities.SPUtility.CheckFrameworkAndProcess() at Microsoft.SharePoint.Administration.SPConfigurationDatabase.get_RegistryConnectionString() at Microsoft.SharePoint.Administration.SPConfigurationDatabase.get_Local() at Microsoft.SharePoint.Administration.SPFarm.FindLocal(SPFarm& farm, Boolean& isJoined) at Microsoft.SharePoint.Administration.SPFarm.get_Local() at Microsoft.SharePoint.SPSite..ctor(String requestUrl) at SPDocumentAPI.Controllers.DocumentController.Get(String docId, String docName, String docLibrary, String newDocLibrary) 在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)

Error Message when application is built under x64 platform in application properties 在应用程序属性中的x64平台下构建应用程序时出现错误消息

Could not load file or assembly 'SPDocumentAPI' or one of its dependencies. 无法加载文件或程序集“ SPDocumentAPI”或其依赖项之一。 An attempt was made to load a program with an incorrect format. 试图加载格式错误的程序。

Stack Trace 堆栈跟踪

[BadImageFormatException: Could not load file or assembly 'SPDocumentAPI' or one of its dependencies. [BadImageFormatException:无法加载文件或程序集'SPDocumentAPI'或其依赖项之一。 An attempt was made to load a program with an incorrect format.] System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0 System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecuri 试图以错误的格式加载程序。] 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, Boolean forIntrospection) +77 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16 System.Reflection.Assembly.Load(String assemblyString) +28 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38 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: Could not load file or assembly 'SPDocumentAPI' or one of its dependencies. [ConfigurationErrorsException:无法加载文件或程序集'SPDocumentAPI'或其依赖项之一。 An attempt was made to load a program with an incorrect format.] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean 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.CallPreStartInitMethods(String preStartInitListPath, 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 appDomainCreationException) +516 试图加载格式不正确的程序。] 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): Could not load file or assembly 'SPDocumentAPI' or one of its dependencies. [HttpException(0x80004005):无法加载文件或程序集'SPDocumentAPI'或其依赖项之一。 An attempt was made to load a program with an incorrect format.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9915300 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254 试图加载格式错误的程序。] System.Web.HttpRuntime.FirstRequestInit(HttpContext上下文)+9915300 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext上下文)+101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr ,HttpContext上下文)+254

Well the project was running on IIS Express and it seems that IIS Express does not compile 64bit applications on Visual Studio 2012. 很好,该项目正在IIS Express上运行,并且IIS Express似乎无法在Visual Studio 2012上编译64位应用程序。

I found this link that explains how to add some changes to the registry. 我发现此链接说明了如何向注册表添加一些更改。

In the end just run the following code on the command prompt and restart the server. 最后,只需在命令提示符下运行以下代码,然后重新启动服务器即可。

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.

相关问题 Microsoft.VisualStudio.Web.Host.exe使用Visual Studio 2012 / WIn7锁定32位进程 - Microsoft.VisualStudio.Web.Host.exe locking 32-bit processes with Visual Studio 2012/WIn7 具有32位依赖项的64位WCF服务 - 64-bit WCF Service with 32-bit dependencies 在32位进程下运行的GhostscriptLibraryNotInstalledException需要本机库 - GhostscriptLibraryNotInstalledException running under 32-bit process requires native library Windows Docker容器中未启动32位进程 - 32-bit process not started in windows docker container JetBrains dotMemory:无法导入转储:当前不支持32位进程的64位转储 - JetBrains dotMemory: Unable to import the dump: 64-bit dumps of 32-bit processes are currently not supported 为什么OleDbConnection在64位进程上引发InvalidOperationException而在32位进程上引发OleDbException - Why OleDbConnection throws InvalidOperationException on 64-bit process and OleDbException on 32-bit process CLR /从32位进程切换到64位进程后的高内存消耗 - CLR / High memory consumption after switching from 32-bit process to 64-bit process 如何以编程方式确定特定进程是 32 位还是 64 位 - How to determine programmatically whether a particular process is 32-bit or 64-bit 从 32 位 Windows 服务使用 64 位进程外 COM DLL - Using 64-bit out of process COM DLL from 32-bit Windows Serivce SetWindowsHookEx将32位DLL注入64位进程,反之亦然 - SetWindowsHookEx is injecting 32-bit DLL into 64-bit process and vice versa
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM