dahall / Vanara

A set of .NET libraries for Windows implementing PInvoke calls to many native Windows APIs with supporting wrappers.
MIT License
1.79k stars 193 forks source link

Unable to create TXT records #466

Closed StefanoN-Infotronics closed 3 months ago

StefanoN-Infotronics commented 4 months ago

Describe the bug and how to reproduce When trying to assign a DATA_TEXT_PTR structure to the Data property of a DNS_RECORD, an out of memory exception occurs. The DATA_TEXT_PTR only has one string in the string array.

A clear and concise description of the bug and how to reproduce it. If an exception is involved, include the full output of the exception (stack trace, message, error code, etc.).

Unhandled exception: System.InsufficientMemoryException: Insufficient memory to continue the execution of the program. at Vanara.Extensions.InteropExtensions.WriteNoChecks(IntPtr ptr, Object value, Int32 offset, SizeT allocatedBytes) at Vanara.Extensions.InteropExtensions.Write(IntPtr ptr, Object value, Int32 offset, SizeT allocatedBytes) at Vanara.PInvoke.DnsApi.DNS_RECORD.set_Data(Object value) at InfoTronics.AOD.AspAdmin.ASPDns.CreateTextDNSEntry(String uri, HdbValues data) in e:\source\projects\Infotronics.AOD.AspAdmin\src\Infotronics.AOD.AspAdmin\ASPDns.cs:line 261 at AspAdminConsoleTest.Engine.Run() in e:\source\projects\Infotronics.AOD.AspAdmin\src\AspAdminConsoleTest\Engine.cs:line 56 at AspAdminConsoleTest.Program.Run(EngineOptions engineOptions, IHost host) in e:\source\projects\Infotronics.AOD.AspAdmin\src\AspAdminConsoleTest\Program.cs:line 81 at System.CommandLine.NamingConventionBinder.CommandHandler.GetExitCodeAsync(Object returnValue) at System.CommandLine.NamingConventionBinder.ModelBindingCommandHandler.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken) at System.CommandLine.Hosting.HostingAction.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken) at System.CommandLine.Hosting.HostingAction.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken) at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken) What code is involved Vanara.PInvoke.DnsApi

The method, file path and library causing the issue. If you have code that will reproduce the bug, please include it here.

Expected behavior It should not have an insufficient memory exception., A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

dahall commented 4 months ago

I am not finding documentation on the internet for DATA_TEXT_PTR. Can you point me to any details? Do you maybe mean the TXT field of type DNS_TXT_DATA? Can you confirm your program is using Unicode instead of Ansi as well?

dahall commented 4 months ago

If a DNS_TXT_DATA, are you setting both fields?

Data = new DNS_TXT_DATA { dwStringCount = 1, pStringArray = ["Test"] }
dahall commented 3 months ago

@StefanoN-Infotronics Is this resolved so we can close it or are you still having the issue?