我们已经实现了一个对Active Directory进行身份验证的成员资格提供程序,它使用的是System.DirectoryServices.在带有webdev服务器的Visual Studio 2010上的ASP.Net MVC 3应用程序中使用此成员资格提供程序时,我们有时(6次中有1次)在登录应用程序时会出现异常.
System.IO.FileNotFoundException: Could not load file or assembly 'System.Web' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Web'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.LoadWithPartialNameInternal(AssemblyName an, Evidence securityEvidence, StackCrawlMark& stackMark)
at System.DirectoryServices.AccountManagement.UnsafeNativeMethods.IADsPathname.Retrieve(Int32 lnFormatType)
at System.DirectoryServices.AccountManagement.ADStoreCtx.LoadDomainInfo()
at System.DirectoryServices.AccountManagement.ADStoreCtx.get_DnsDomainName()
at System.DirectoryServices.AccountManagement.ADStoreCtx.GetGroupsMemberOfAZ(Principal p) …Run Code Online (Sandbox Code Playgroud) 给出以下json结果:默认的json结果有一组已知的字段:
{
"id": "7908",
"name": "product name"
}
Run Code Online (Sandbox Code Playgroud)
但可以用额外的字段(在此示例中被扩展_unknown_field_name_1和_unknown_field_name_2其中的请求结果,当名称不知道).
{
"id": "7908",
"name": "product name",
"_unknown_field_name_1": "some value",
"_unknown_field_name_2": "some value"
}
Run Code Online (Sandbox Code Playgroud)
我希望将json结果序列化并反序列化为具有已知字段属性的类,并将未知字段(没有属性)映射到属性(或多个属性),如字典,这样它们就可以了访问和修改.
public class Product
{
public string id { get; set; }
public string name { get; set; }
public Dictionary<string, string> fields { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我想我需要一种方法来插入一个json序列化器并自己为缺失的成员做映射(用于序列化和反序列化).我一直在寻找各种可能性:
我正在使用restsharp,但可以插入任何序列化程序.
更新: 看起来更像它:http://geekswithblogs.net/DavidHoerster/archive/2011/07/26/json.net-custom-convertersndasha-quick-tour.aspx
我有以下包装器:
public interface ITransactionScopeWrapper : IDisposable
{
void Complete();
}
public class TransactionScopeWrapper : ITransactionScopeWrapper
{
private readonly TransactionScope _scope;
private readonly ISession _session;
private readonly ITransaction _transaction;
public TransactionScopeWrapper(ISession session)
{
_session = session;
_scope = new TransactionScope(TransactionScopeOption.Required,
new TransactionOptions {IsolationLevel = IsolationLevel.ReadCommitted});
_transaction = session.BeginTransaction();
}
#region ITransactionScopeWrapper Members
public void Dispose()
{
try
{
_transaction.Dispose();
}
finally
{
_scope.Dispose();
}
}
public void Complete()
{
_session.Flush();
_transaction.Commit();
_scope.Complete();
}
#endregion
}
Run Code Online (Sandbox Code Playgroud)
在我的ActionFilter中,我有以下内容:
public class NhibernateTransactionAttribute : ActionFilterAttribute …Run Code Online (Sandbox Code Playgroud) 我已经可以将文件另存为.jpeg,但是图像无法加载,有人建议吗?
Private Sub Btnconfirm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnconfirm.Click
MsgBox("A receipt will now be saved to your files", vbOKOnly, "Thank you for your purchase")
SaveFileDialog1.ShowDialog()
MsgBox("Thank you for choosing Tiny Theatre, have a nice day.", vbOKOnly, "Thank you")
Me.Close()
End Sub
Private Sub SaveFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
Dim FileToSaveAs As String = SaveFileDialog1.FileName
Dim objwriter As New System.IO.StreamWriter(FileToSaveAs)
objwriter.Write(PictureBox1)
objwriter.Close()
End Sub
Run Code Online (Sandbox Code Playgroud)