我收到此错误:
由于其保护级别,'CTest.AA()'无法访问.
编译此代码时:
public class A
{
private A()
{
}
}
public class B : A
{
public void SayHello()
{
Console.WriteLine("Hello");
}
}
Run Code Online (Sandbox Code Playgroud)
有谁能解释为什么?
我想知道如何用wcf编写wsdl.据我所知,代理类序列化数据并形成一条肥皂消息通过网络发送,同样,我想知道是谁编写了wsdl文件并负责序列化调用结果.
我创建了一个名为AddServiceLibrary的类库,其中我有一个名为AssemblyLoader的方法,代码如下:
string executingAssemblyName = Application.ExecutablePath;
AssemblyName asmName = AssemblyName.GetAssemblyName(executingAssemblyName);
AppDomain appDomain = AppDomain.CurrentDomain;
Assembly assembly = appDomain.Load(asmName);
_assemblyTypes = assembly.GetTypes().ToList();
LoadAppConfig();
Run Code Online (Sandbox Code Playgroud)
此方法在当前appdomain中加载执行程序集.我有另一种叫做LoadAppConfig()的方法
ServicesSection serviceSection = ConfigurationManager.GetSection("system.serviceModel/services") as ServicesSection;
ServiceElementCollection sereleColl = serviceSection.Services;
string endPointAddress = string.Empty ;
foreach (var ele in sereleColl)
{
_serviceType = GetServiceType((System.ServiceModel.Configuration.ServiceElement)(ele)).Name);
break;
}
ServiceHoster.HostService(_serviceType);
Run Code Online (Sandbox Code Playgroud)
此方法读取app.config文件并查找wcf服务的类型.我有一个类ServiceHoster我有一个方法HostService:
public static void HostService(Type serviceType)
{
using (ServiceHost host = new ServiceHost(serviceType))
{
host.Open();
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我有一个名为MyWCFService的不同项目,我在这个项目中添加AddServiceLibrary的引用并调用该方法;
AddServiceLibrary.LoadLibrary lb = new AddServiceLibrary.LoadLibrary();
lb.AssemblyLoader();
Run Code Online (Sandbox Code Playgroud)
我希望在这一点上我的服务是正确托管的,但是当我想在我的客户端项目中使用AddServiceReference时,它告诉我,由于目标机器主动拒绝它,因此 无法建立连接. 如果我不使用我的AddServiceLibrary,那么它是找到服务并且工作正常.请任何人看看它,并建议我的方法可能是错的.
我是Web技术的新手,我想知道Session的用法。Session的基本用途是什么,它仅用于保存体数据还是有其他用途?
可能重复:
何时传递ref关键字
大家好,
我很惊讶我们为什么ref在C#中默认情况下,C#中的所有引用类型都作为引用传递.
简单来说,任何人都可以解释这两个方法调用之间的区别:
public void Test(SomeClass someClass)
{
// some code here
}
Run Code Online (Sandbox Code Playgroud)
和
public void Test(ref SomeClass someClass)
{
// some code here
}
Run Code Online (Sandbox Code Playgroud)
在我的想法中,他们都参考了相同的内存位置.
那么为什么我们需要ref关键词呢?
我看到当我调用类的实例方法时,C#编译器会发出callvirt调用该方法的
指令,为什么会这样呢?
这是否意味着所有实例方法都被virtual methods编译器视为什么,这是什么谜?
我想澄清一些与Web服务和WCF相关的疑问.以下是我的疑惑..
httpGetEnabled = true,为什么可以通过使用创建一个代理类AddServiceReference,我的意思是如何有人访问我的服务细节,直到我不穿暴露mex端点.请帮助我解决上述问题中的疑虑.
c# ×5
wcf ×3
.net ×2
asp.net ×1
comparison ×1
constructor ×1
web-services ×1
winforms ×1
wsdl ×1