本文介绍了当我在Web应用程序中添加lib的引用时,如何仅公开lib的类成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


如何将我的类库(.dll)的成员暴露给Web应用程序Asp.net.

我建立了一个类库,此库已添加到我的Web应用程序中作为参考.但是知道,我希望我的Web应用程序访问我的lib(.dll类)属性,而不是我的.dll方法.
因此,请告诉我我在类库(.dll)中的操作,以便仅公开成员(属性),而不公开方法.


谢谢&问候
Chiranjeevi Ommi

[edit]代码从解决方案"移至问题-OriginalGriff [/edit]



如果我将其更改为私有,则会收到错误消息.

我将在这里粘贴示例代码,请帮我做.

*****************************

Hi
how to expose members of my class library(.dll) to my web application Asp.net.

i build a class library and this lib was added to my web application as a reference. But know, i want my web application to access my lib(.dll class) properties but not the methods of my .dll

so please tell me what i have do in my class lib (.dll) so that i will expose only members (properties) but not it methods.


Thanks & Regards
chiranjeevi Ommi

[edit]Code moved from Solution to question - OriginalGriff[/edit]

Hi

i am getting error, if i change them to private.

i will past my sample code here, pls help me hoe to do it.

*****************************

   namespace TestDLL
    {
        
        Public sealed class A
        {
            private static volatile A instance = null;
            private static object myLock = new object();
            public B siteConfig = null;
    
            private A()
            {
                objB = new B();
                objB.ReadXml();
            }
    
            public static A Instance
            {
                get
                {
                    if (instance == null)
                    {
                        lock (myLock)
                        {
                            if (instance == null)
                            {
                                instance = new A();
                            }
                        }
                    }
                    return instance;
                }
            }
        }
        
        Public class B
        {
            private string virP = string.Empty;
            private string rootP = string.Empty;
            private string conP = string.Empty;
            
            public string VirP
            {
                get { return vir; }
                set { virP = value; }
            }
            public string ConP
            {
                get { return conP; }
                set { conP = value; }
            }
            public string RootP
            {
                get { return rootP; }
                set { rootP = value; }
            }
            
            public void ReadXML()
            {
            virP="";
            ConP="";
            RootP="";
            
        }
    }

}




**************************


当我将DLL添加到Web应用程序中时,我应该只能看到VirP,ConP和RootP,但是只能看到方法"ReadXML".即使我更改为私有也不会发生.

谢谢&问候
奇兰杰耶夫
改善解决方案Permalink |发表于9分钟前
ommi.chiru724




**************************


when i add my DLL to my web application, i should see only VirP,ConP and RootP but the method "ReadXML". which is not happening even i change to Private.

Thanks & Regards
Chiranjeevi
Improve solution Permalink | Posted 9 mins ago
ommi.chiru724

推荐答案



这篇关于当我在Web应用程序中添加lib的引用时,如何仅公开lib的类成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 07:31