我有下一个XML文件:
<Root>
<Document>
<Id>d639a54f-baca-11e1-8067-001fd09b1dfd</Id>
<Balance>-24145</Balance>
</Document>
<Document>
<Id>e3b3b4cd-bb8e-11e1-8067-001fd09b1dfd</Id>
<Balance>0.28</Balance>
</Document>
</Root>
Run Code Online (Sandbox Code Playgroud)
我把它反序列化到这个类:
[XmlRoot("Root", IsNullable = false)]
public class DocBalanceCollection
{
[XmlElement("Document")]
public List<DocBalanceItem> DocsBalanceItems = new List<DocBalanceItem>();
}
Run Code Online (Sandbox Code Playgroud)
在哪里DocBalanceItem
:
public class DocBalanceItem
{
[XmlElement("Id")]
public Guid DocId { get; set; }
[XmlElement("Balance")]
public decimal? BalanceAmount { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这是我的反序列化方法:
public DocBalanceCollection DeserializeDocBalances(string filePath)
{
var docBalanceCollection = new DocBalanceCollection();
if (File.Exists(filePath))
{
var serializer = new XmlSerializer(docBalanceCollection.GetType());
TextReader reader = new StreamReader(filePath);
docBalanceCollection = (DocBalanceCollection)serializer.Deserialize(reader);
reader.Close(); …
Run Code Online (Sandbox Code Playgroud) 最近,我们在安装了VSTS构建代理的构建代理(运行Windows 2016的两台单独安装的计算机)上遇到了一个烦人的问题。当我们运行del "\\?\%CD%\nul"
(请参阅超级用户)时,它会运行几个版本,然后再次出现。
如何以及为什么创建该文件,以及如何确保构建代理不会中断?
下面的堆栈跟踪:
Failed to create Release artifact directory C:\agent\_work\r1\a with an exception
Microsoft.VisualStudio.Services.Agent.Worker.Release.Artifacts.ArtifactDirectoryCreationFailedException: Failed to create Release artifact directory 'C:\agent\_work\r1\a'. ---> System.UnauthorizedAccessException: Access to the path 'C:\agent\_work\r1\a\NUL' is denied.
at System.IO.Win32FileSystem.DeleteFile(String fullPath)
at System.IO.FileInfo.Delete()
at Microsoft.VisualStudio.Services.Agent.Util.IOUtil.c__DisplayClass26_1.b__0(FileSystemInfo item)
at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
at System.Linq.Parallel.SpoolingTaskBase.Work()
at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
at System.Linq.Parallel.QueryTask.RunTaskSynchronously(Object o)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.Services.Agent.Worker.Release.ReleaseFileSystemManager.EnsureEmptyDirectory(String directoryPath, CancellationToken …
Run Code Online (Sandbox Code Playgroud) build build-agent nul azure-devops azure-devops-self-hosted-agent
我们在MemoryMappedFile中加载了一个222MB的文件,用于原始数据访问.使用write方法更新此数据.经过一些计算后,数据应重置为文件的原始值.我们目前通过部署类并创建新实例来实现这一点.这种情况很好,但有时CreateViewAccessor崩溃时出现以下异常:
System.Exception:没有足够的存储空间来处理此命令.---> System.IO.IOException:没有足够的存储空间来处理此命令.
at System.IO .__ Error.WinIOError(Int32 errorCode,String maybeFullPath)在System.IO.MemoryMappedFiles.MemoryMappedFile.CreateViewAccessor的System.IO.MemoryMappedFiles.MemoryMappedView.CreateView(SafeMemoryMappedFileHandle> memMappedFileHandle,MemoryMappedFileAccess访问,Int64偏移,Int64大小)处. Int64偏移量,Int64>大小,MemoryMappedFileAccess访问权限)
以下类用于访问memorymapped文件:
public unsafe class MemoryMapAccessor : IDisposable
{
private MemoryMappedViewAccessor _bmaccessor;
private MemoryMappedFile _mmf;
private byte* _ptr;
private long _size;
public MemoryMapAccessor(string path, string mapName)
{
FileInfo info = new FileInfo(path);
_size = info.Length;
using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Delete | FileShare.ReadWrite))
_mmf = MemoryMappedFile.CreateFromFile(stream, mapName, _size, MemoryMappedFileAccess.Read, null, HandleInheritability.None, false);
_bmaccessor = _mmf.CreateViewAccessor(0, 0, MemoryMappedFileAccess.CopyOnWrite);
_bmaccessor.SafeMemoryMappedViewHandle.AcquirePointer(ref _ptr);
}
public void Dispose()
{
if (_bmaccessor != …
Run Code Online (Sandbox Code Playgroud) 我们已使用本教程启用托管标识以连接到 Azure 上的 Identity Server 数据库,但一段时间(约 7 小时)后出现以下错误。
System.Data.SqlClient.SqlException (0x80131904): Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnection
PoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal …
Run Code Online (Sandbox Code Playgroud) sql-server azure entity-framework-core asp.net-core identityserver4
尝试调试Any CPU控制台应用程序时,我收到以下错误.当我将平台目标切换到x86时,它工作正常.我试图修复VS2010并重新安装VS2010.
完整的错误消息是: 错误消息http://www.bacolan.com/vs-error.png
除了完整的Windows重新安装外,有没有人有解决方案?
c# ×2
.net ×1
64-bit ×1
asp.net-core ×1
azure ×1
azure-devops ×1
azure-devops-self-hosted-agent ×1
build ×1
build-agent ×1
debugging ×1
generics ×1
nul ×1
sql-server ×1