问题描述
我有一个停留在ASP.NET 2.0中的免费托管服务.此外,它将用户限制为仅内联版本(无代码隐藏).但是,它确实允许引用自定义组件.我已经构建了一个内联.asmx,理想情况下,我想包含"/使用"我已构建的组件.我该如何内联?我已经尝试过'使用[命名空间]',但是出现编译错误.我也曾尝试在WebMethod [组件的命名空间].[Method]中使用.同样,这会产生编译错误.我似乎在其他地方找不到任何有关如何执行此操作的文档.该组件未编译到DLL中,如果以Web形式引用,则可以正常工作.
I have a free hosting service that is stuck in ASP.NET 2.0. Additionally, it constrains users to only inline versions (no codebehind). However, it does allow references to custom components. I have built an inline .asmx and would, ideally, like to 'include'/'use' a component I've built. How do I do this inline? I've tried 'using [Namespace]', but get a compilation error. I've also tried using, in the WebMethod [Namespace of Component].[Method] as well. Again, this produces a compilation error. I can't seem to find any documentation on how to do this else where. The component is not compiled into a DLL and will work if referenced in a web form.
推荐答案
使用Import
指令导入名称空间:
Use the Import
directive to import a namespace:
<%@ Import namespace="My.Namespace" %>
编辑:对于错误信息,我们深表歉意.您将对ASMX Web服务使用Assembly
指令:
EDIT: Sorry for the misinformation. You'll want to use the Assembly
directive for an ASMX web service:
<%@ Assembly Name="MyAssembly" %>
或
<%@ Assembly Src="path/myFile.cs" %>
由于您引用的代码未编译,因此您将需要使用指令的后一版本来指向源文件. Src
属性指向动态编译和链接的源文件.
Since the code you are referencing is not compiled, you'll want to use the latter version of the directive to point to the source file. The Src
attribute points to a source file to dynamically compile and link against.
这篇关于如何在嵌入式Web服务中引用组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!