.NET Framework
97 TopicsConnection between .NET and AUTOCAD ELECTRICAL
I want to connect .NET with Autocad Electrical . i am using , AutoCAD Electrical 2025.0.2 , Product Version : 22.0.81.0 , Built on: V.154.0.0 AutoCAD 2025.1.1 Visual Studio Community 2022 - 17.12.3 my system is x64 bit I am creating a console application in .NET 8.0 Runtime with C# language , Added dll accoremgd , acdbmgd, acmgd, Autodesk.AutoCAD.Interop . Also in .NET in Solution Explorer , in project references , i have made "Copy Local" property as False. using System; using Autodesk.AutoCAD.Interop; using Autodesk.AutoCAD.Runtime; using System.Runtime.InteropServices; using Autodesk.AutoCAD.ApplicationServices; namespace AutoCADElecDemo { class Program { static void Main(string[] args) { AcadApplication acadApp = null; const string progId = "AutoCAD.Application.25"; // Adjust for your AutoCAD version try { // Get a running instance of AutoCAD acadApp = GetActiveAutoCAD(progId); } catch (System.Exception ex) { Console.WriteLine($"Error initializing AutoCAD: {ex.Message}"); return; } try { // Ensure AutoCAD is visible acadApp.Visible = true; Console.WriteLine("AutoCAD is now running."); // Register for the BeginQuit event Application.BeginQuit += OnBeginQuit; // Keep the application running to monitor AutoCAD's state Console.WriteLine("Press Enter to exit..."); Console.ReadLine(); } catch (System.Exception ex) { Console.WriteLine($"An error occurred: {ex.Message}"); } finally { // Unregister the event handler before exiting Application.BeginQuit -= OnBeginQuit; } } static AcadApplication GetActiveAutoCAD(string progId) { try { var comObject = Marshal.GetActiveObject(progId); Console.WriteLine($"Connected to AutoCAD: {progId}"); return (AcadApplication)comObject; } catch (System.Exception ex) { Console.WriteLine($"Error accessing AutoCAD: {ex.Message}"); throw; } } static void OnBeginQuit(object sender, EventArgs e) { Console.WriteLine("AutoCAD is being closed."); } } } For above code, my application comes in break mode "Your app has entered a break state, but no code is currently executing that is supported by the selected debug engine (e.g. only native runtime code is executing)." and i am getting below error : System.IO.FileNotFoundException: 'Could not load file or assembly 'accoremgd, Version=25.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.' dll path is also correct. i also tried same code with .NET Framework 4.7.2 and 4.8 targeting pack , but getting same error. How to load accoremgd.dll properly so that this application can use autocad accoremgd functions properly.115Views0likes2CommentsCan't able to Upload Images on Azure Server if it is more than 128KB
Hi Everyone , I am trying to upload image and store but when i do it in my local server its working fine but when i push the same code in server i am getting entity too large I reached out microsoft support they are telling that "The content type format is supposed to be image as example given to upload the image file otherwise the application gateway will not understand the image and tries to accept only 128KB which is why the request is not accepted with Application Gateway. " when i am debugging i am getting same content type = image/jpeg . Code snippet for storing private void SaveImage(int vendItemID) { try { string folderPath = @"C:\UploadedImages\"; Directory.CreateDirectory(folderPath); string fileExtension = Path.GetExtension(fileUpload.FileName).ToLower(); string fileName = Path.GetFileNameWithoutExtension(fileUpload.FileName); string newImageName = string.Empty; dbCon.Server = "***"; dbCon.OpenConnection(); // Optimize and compress the image byte[] optimizedImageBytes = CompressImageToTargetSize(fileUpload.PostedFile.InputStream, fileExtension); // Convert to Base64 string base64String = Convert.ToBase64String(optimizedImageBytes); using (SqlCommand cmd = new SqlCommand("***", dbCon.Cnn)) { cmd.CommandType = CommandType.StoredProcedure; AddImageParameters(cmd, vendItemID, fileName, fileExtension); cmd.Parameters.AddWithValue("@ImageBase64", base64String); var outputCodeParam = new SqlParameter("@ImageNewName", SqlDbType.NVarChar, 200) { Direction = ParameterDirection.Output }; cmd.Parameters.Add(outputCodeParam); cmd.ExecuteNonQuery(); newImageName = outputCodeParam.Value.ToString(); } string newFilePath = Path.Combine(folderPath, newImageName); File.WriteAllBytes(newFilePath, optimizedImageBytes); UpdateImagePath(newImageName, newFilePath); } catch (Exception ex) { ShowMessage("Error while saving image: " + ex.Message, Color.Red); LogError("Image save failed", ex); throw; } finally { dbCon.CloseConnection(); } } I also try to compress and change it to base 64 but its not working. Kindly assist on what steps i need to take. Thanks, Shahid Note :WebForm i m working on .13Views0likes0Comments.Net 8 Isolated upgrade issue- RPC Exceptions in .Net Core Function App
Hi Team, Need Immediate help. I am continuously receiving RPC Exceptions when I have upgraded my Function App to .Net 8 previously I had zero exceptions related to this in .Net 6. Scenario: We are creating builder with ConfigureFunctionsWebApplication() like below: 1. var builder = FunctionsApplication.CreateBuilder(args); 2. builder.ConfigureFunctionsWebApplication(); And basically, we have Http triggers and SB triggers in the application and only couple of them are facing issue and the error in AI states that this is an issue related to worker. I have copied multiple exception wrapped as an RPC exception below: 1. An exception was thrown by the invocation. Exception: System.TimeoutException: Timed out waiting for the function start call. 2. The operation has timed out at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.DefaultHttpCoordinator.SetFunctionContextAsync(String invocationId, FunctionContext context) 3.Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.DefaultHttpCoordinator.SetFunctionContextAsync(String invocationId, FunctionContext context) 4. Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\FunctionsMiddleware\FunctionsHttpProxyingMiddleware.cs:line 45 at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a\_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 96 Stack: at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.DefaultHttpCoordinator.SetFunctionContextAsync(String invocationId, FunctionContext context) in D:\a\_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\Coordinator\DefaultHttpCoordinator.cs:line 66 5. Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\FunctionsMiddleware\FunctionsHttpProxyingMiddleware.cs:line 45 at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a\_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 9660Views0likes0CommentsDuck Game Crashes
I am hoping that someone here might be able to steer me in the right direction. I have posted in the game's forum, but I am not receiving any support there. I have a new laptop running Windows 11. We are getting frequent game crashes while playing Duck Game. I am wondering if it is a compatibility issue as the game is older. Any help would be GREATLY appreciated. Here is our most recent crash report: System.InvalidOperationException: An unexpected error has occurred. at Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawUserIndexedPrimitives[T](PrimitiveType primitiveType, T[] vertexData, Int32 vertexOffset, Int32 numVertices, Array indexData, Int32 indexOffset, Int32 primitiveCount, VertexDeclaration vertexDeclaration, _D3DFORMAT indexFormat) at DuckGame.MTSpriteBatcher.FlushVertexArray(Int32 start, Int32 end) in C:\gamedev\duckgame_current_steam\duckgame\DuckGame\src\MonoTime\Render\SpriteBatcher.cs:line 709 at DuckGame.MTSpriteBatcher.DrawBatch(SpriteSortMode sortMode) in C:\gamedev\duckgame_current_steam\duckgame\DuckGame\src\MonoTime\Render\SpriteBatcher.cs:line 485 at DuckGame.MTSpriteBatch.End() in C:\gamedev\duckgame_current_steam\duckgame\DuckGame\src\MonoTime\Render\MTSpriteBatch.cs:line 151 at DuckGame.Layer.End(Boolean transparent, Boolean isTargetDraw) in C:\gamedev\duckgame_current_steam\duckgame\DuckGame\src\MonoTime\Layer.cs:line 897 at DuckGame.Layer.Draw(Boolean transparent, Boolean isTargetDraw) in C:\gamedev\duckgame_current_steam\duckgame\DuckGame\src\MonoTime\Layer.cs:line 1154 at DuckGame.LayerCore.DrawLayers() in C:\gamedev\duckgame_current_steam\duckgame\DuckGame\src\MonoTime\Layer.cs:line 381 at DuckGame.Level.DoDraw() in C:\gamedev\duckgame_current_steam\duckgame\DuckGame\src\MonoTime\Level.cs:line 1081 at DuckGame.Level.DrawCurrentLevel() in C:\gamedev\duckgame_current_steam\duckgame\DuckGame\src\MonoTime\Level.cs:line 198 at DuckGame.MonoMain.RunDraw(GameTime gameTime) in C:\gamedev\duckgame_current_steam\duckgame\DuckGame\src\MonoTime\MonoMain.cs:line 2524 at DuckGame.MonoMain.Draw(GameTime gameTime) in C:\gamedev\duckgame_current_steam\duckgame\DuckGame\src\MonoTime\MonoMain.cs:line 2246 Last 8 Lines of Console Output: Creating ghost (1442) @received Activating NMItemSpawned (2044->2045)((0)(H)LawMac,76561198093753884)(16) @received Activating NMFireGun (2045->2046)((0)(H)LawMac,76561198093753884)(16) @sent Sent NMKillDuck (421)((0)(H)LawMac,76561198093753884)(16) Creating ghost (1443) @received Activating NMItemSpawned (2046->2047)((0)(H)LawMac,76561198093753884)(16) Creating ghost (8879) Creating ghost (8880) Date: 04/19/2024 03:58:56 Version: 1.1.7717.16376 Platform: Windows 10 (Steam Build 8782838)(SFX) Online: 1 (C,0.01582697) Mods: nomods Time Played: 00:39:02 (140607) Special Code: men20 Resolution: (A)1920x1080 (G)1920x1080 (Fullscreen(W))(RF 140420) Level: Content/levels/deathmatch/office01_8.lev Command Line:1.3KViews0likes3Comments🚀 Kickstart Your .NET Journey with Microsoft Learn!
Hey .NET enthusiasts! Are you new to .NET or looking to refresh your skills? Microsoft Learn has an Introduction to .NET module that walks you through the fundamentals of .NET, .NET Core, and the .NET Framework. This is a free, hands-on learning experience designed to get you started quickly. What you'll learn: The basics of .NET and why it's powerful How .NET supports multiple platforms Running your first .NET application Start learning here: Microsoft Learn Introduction to .NET Have you used .NET in your projects? Share your experiences and let’s discuss below!44Views0likes0CommentsMysql connection error
Hello, I need help with a connection with C#. I have a database that I just dumped, the connection with the mysql.data tools was working perfectly, but after the dump I get this error: Unable to cast object of type 'System.DBNull' to other types in System.DBNull.System.IConvertible.ToInt32(IFormatProvider provider) in System.Convert.ToInt32(Object value, IFormatProvider provider) in MySql.Data.MySqlClient.Driver.<LoadCharacterSetsAsync>d__81.MoveNext() --- Fine traccia dello stack da posizione precedente dove è stata generata l'eccezione --- in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in MySql.Data.MySqlClient.Driver.<ConfigureAsync>d__78.MoveNext() --- Fine traccia dello stack da posizione precedente dove è stata generata l'eccezione --- in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) in MySql.Data.MySqlClient.MySqlConnection.<OpenAsync>d__94.MoveNext() --- Fine traccia dello stack da posizione precedente dove è stata generata l'eccezione --- in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in MySql.Data.MySqlClient.MySqlConnection.Open() in DBTester.FormMain.btnTest_Click(Object sender, EventArgs e) in C:\Users\... The absurd thing is that if I try several times, on the fourth or fifth attempt it succeeds, has anyone ever encountered this problem, or can they help me figure out what may have gone wrong? Now DB works on MariaDB 11, the old db was on MariaDB 8 What can I verify?103Views1like1CommentGet certificate's public key in the PKCS8 format
Environment: Windows 11 24H2 .Net Framework 4.8, 4.7.2 Problem: I do not understand how to get server's certificate public key in PKCS8 format using the X509Certificate class. Explanation: I'm implementing the custom server's certificate check for SSL connection (aka certificate pinning) in the next way: Create a new SSLStream: SslStream sslStream = new SslStream( client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null); Declare the ValidateServerCertificate() method: public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {} Get server's certificate public key certificate.GetPublicKey() The public key which I get is in the PKCS1 format and I can't find any function in .Net Framework to get it in the PKCS8 format or to convert from PCKS1 to PKCS8. As a fallback, I'm using the static prefix for the PKCS8 format which works well but is valid only for 2048 bits long public keys: private static byte[] pkcs8Prefix = { 0x30, 0x82, 0x01, 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0F, 0x00 }; byte[] pkcs8PublicKey = pkcs8Prefix.Concat(certificate.GetPublicKey()).ToArray(); Which function of .Net Framework can I use to get the public key in the PKCS8 format?38Views0likes0Comments