How do I reference a component in an inline web service?

给你一囗甜甜゛ 提交于 2019-12-11 05:10:00

问题


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.


回答1:


Use the Import directive to import a namespace:

<%@ Import namespace="My.Namespace" %>

EDIT: Sorry for the misinformation. You'll want to use the Assembly directive for an ASMX web service:

<%@ Assembly Name="MyAssembly" %>

or

<%@ Assembly Src="path/myFile.cs" %>

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.



来源:https://stackoverflow.com/questions/8345875/how-do-i-reference-a-component-in-an-inline-web-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!