AspPDF和ASPJPEG在Windows Azure上ASPJPEG、AspPDF、Azure、Windows

2023-09-03 17:07:24 作者:囍战

最近我又开始了我们的.NET应用程序迁移到Windows Azure云服务的过程。我们应用在很大程度上取决于若干COM类组分,这些包括AspPDF(针对PDF生产和操作)和ASPJPEG(用于图像大小调整)。在一个典型的非云IIS安装我只想注册的DLL(使用REGSVR32)我们的生产服务器上,一切都会好起来!

I have recently began the process of migrating our .NET Application to a Windows Azure cloud service. Our application was heavily dependent on a number of COM Class components, these include AspPDF (for PDF production and manipulation) and AspJPEG (for image re-sizing). On a typical non-cloud IIS setup I would just register the DLLs (using regsvr32) on our production server and all would be fine!

在Azure的过程略有不同,我会回答我的问题,以帮助那些有类似的挑战。这种方法可用于为需要在服务器上注册为部署过程的一部分任何DLL

In Azure the process is slightly different and I will answer my own question to assist those with similar challenges. This method can be used for any dll that needs to be registered on the server as part of the deployment process.

推荐答案

为了注册AspPDF和ASPJPEG组件在Windows Azure云服务的DLL注册过程必须纳入部署程序。当Azure的解压缩应用程序必须激发一个命令来注册这些DLL,这必须在所有的虚拟机仍然存在,以确保这些依赖在云环境中持续工作。

In order to register the AspPDF and AspJPEG components on a Windows Azure cloud service the DLL registration process must be incorporated into the deployment routine. When Azure unpacks the application it must fire a command to register the DLLs, this must be persisted on all VMs to ensure these dependencies work consistently in a cloud environment.

要实现这一点,我们可以指示目标服务器上执行的命令文件。这个任务是在ServiceDefinition.csdef中文件定义如下:

To achieve this we can instruct a command file to be executed on the target server. This task is defined in the ServiceDefinition.csdef file as follows:

<Startup>
  <Task commandLine="RegisterPersits.cmd" executionContext="elevated" taskType="simple" />
</Startup>

升高的执行环境,确保这一进程必须进行之前,该服务上线。在Azure结构控制器看起来在bin文件夹中.cmd文件。您可以创建在记事本中的.cmd,然后更改扩展名。这里是.cmd文件的内容。

The elevated execution context ensures that this process must be carried out before the service goes live. The Azure Fabric Controller will look in the BIN folder for the .cmd file. You can create the .cmd in Notepad and then change the extension. Here is the contents of the .cmd file.

chcp 1252>NUL
regsvr32 /s .\library\asppdf64.dll
regsvr32 /s .\library\aspjpeg64.dll
exit /b 0

我们正在调用REGSVR32工具与参数/ S,这确保了反应是沉默的,即没有弹出式窗口,将混淆网络控制器。这很重要,因为我浪费了大量的时间想知道为什么在部署过程中挂在初始化阶段...添加/ S参数,解决了这个问题!

We are calling the regsvr32 tool with the parameter /s, this ensures that the response is silent, i.e. no pop-ups that will confuse the fabric controller. This is important as I wasted a great deal of time wondering why the deployment process was hanging on the initialisation phase...adding the /s parameters solved this problem!

在我的情况,我把DLL的一个名为库的文件夹中,但你可以把它们放在你喜欢的地方,提供它们在.cmd文件正确引用。另请确保在Visual Studio中的启动命​​令中引用的DLL设置下列文件属性:

In my case I placed the DLLs in a folder called library, but you can put them wherever you like providing they are correctly referenced in the .cmd file. Be sure also to set the following file properties for any DLL referenced in the startup command within Visual Studio:

生成操作:内容

复制到输出目录:总是

这对于注册DLL额外的过程中添加的时间几乎可以忽略量的部署过程。另外一个针对AspPDF点,是使用正确的DLL版本的重要性。 Persits发出32位和64位的DLL,Azure的虚拟机在64位环境中运行,因此注册asppdf64.dll在上述过程中,注册一个32位的DLL将您的应用程序中抛出一个模糊的错误是很重要的。幸运的是,你并不需要购买单独的许可证为64位版本的AspPDF的。

This additional process for registering DLLs adds an almost negligible amount of time to the deployment process. One other point specific to AspPDF, is the importance of using the correct DLL version. Persits issue a 32 bit and 64 bit dll, Azure VMs run in an 64 bit environment therefore it's important to register the asppdf64.dll in the above process, registering a 32 bit dll will throw a vague error within your application. Fortunately you do not need to purchase a separate licence for the 64 bit version of AspPDF.

我希望这将帮助其他面临类似问题的迁移COM类组件如AspPDF天青。

I hope this will assists others facing similar problems migrating com class components such as AspPDF to Azure.