我正在尝试使用该CurrentDomain.AssemblyResolve事件来加载标记为嵌入式资源的DLL.我的问题,具体来说,是因为我试图将程序集用作子类,如下所示:
#define BROKEN
using System;
using System.Reflection;
using TestCompanyInc;
namespace TestConsole
{
#if BROKEN
// This is how I NEED to use it
class Program : SubClass
#else
// This is only here as a test to make sure I wired
// CurrentDomain.AssemblyResolve correctly
class Program
#endif
{
static int Main(string[] args)
{
AppDomain.CurrentDomain.AssemblyResolve += (sender, eventArgs) =>
{
string resourceName = Assembly.GetExecutingAssembly()
.GetName().Name
+ "." + new AssemblyName(eventArgs.Name).Name + ".dll";
Console.WriteLine("About to lookup {0}", resourceName);
using (var …Run Code Online (Sandbox Code Playgroud) 我在c#中寻找一种方法来重置文件的权限,以便从父项继承,就像创建文件或将文件复制到该目录一样.
从文件的角度来看,我似乎无法找到任何内容(我找到了一个或两个目录的引用,但由于某种原因我无法将它们转换为文件).例如,C# - Windows ACL - 应用继承权限.但我不确定LOGON_USER_NAME应该是什么价值,并且我可以得到的是System.ArgumentExcpetion"没有标志可以设置"
我有一个Web服务,我在三个负载平衡的Web服务器上运行,我得到零星的错误.现在,我承认负载平衡部分可能有点红鲱鱼,但是当我只用1个Web服务器进行测试时,我无法重现错误.如果我测试所有三个Web服务器,我可以得到错误(但它不是100%的时间,更像是50%).所有测试都是通过负载均衡器完成的,我们只告诉负载均衡器我们想要多少台服务器.
代码是简单的单个请求代码.也就是说,没有国家.发出请求并返回响应.Web服务代码是在IIS 7.5上运行的c#.NET 4.客户端代码既是网站又是桌面应用程序.
我得到两个例外之一:
System.ServiceModel.Security.MessageSecurityException:从另一方收到了不安全或不正确安全的故障.请参阅内部FaultException以获取故障代码和详细信息.---> System.ServiceModel.FaultException:安全上下文令牌已过期或无效.邮件未处理.
或者我得到:
System.ServiceModel.Security.SecurityNegotiationException:无法打开安全通道,因为与远程端点的安全协商失败.这可能是由于在用于创建通道的EndpointAddress中缺少或错误指定了EndpointIdentity.请验证EndpointAddress指定或暗示的EndpointIdentity是否正确标识远程端点.---> System.ServiceModel.FaultException:安全令牌请求包含无效或格式错误的元素.
从我的.config文件中可以看到以下剪辑,我没有使用安全性,因为这严格来说是一个内部Web服务.(名称已被更改以保护无辜者 - 即我).
服务器端:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- Service Side web.config -->
...
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="InternalUseOnly.InternalUseOnlyServiceBehavior" name="InternalUseOnly.InternalUseOnlyService">
<endpoint address="" bindingNamespace="http://somecompany.com/webservices" binding="wsHttpBinding" contract="InternalUseOnly.IInternalUseOnlyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="InternalUseOnly.InternalUseOnlyServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
...
</configuration>
Run Code Online (Sandbox Code Playgroud)
客户端
<?xml version="1.0" encoding="UTF-8"?>
<!-- Client Side web.config -->
<configuration>
...
<system.serviceModel>
<bindings>
<wsHttpBinding> …Run Code Online (Sandbox Code Playgroud)