Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all 8156 articles
Browse latest View live

Possibility of CAD drawing using ASP.Net Web API

$
0
0

I am looking for CAD drawing API thatshould have the ability to draw the shapes of various stages in metal forming. I came across several blogs that all only have the basic shapes. I need to know is there any possibility of draw kind of shapes involving in various stages of metal forming.

Kindly let me know is there any API available in .net to achieve this and If API available for Web version that would be appreciable.






How to get outgoing IP address of web application on a shared host

$
0
0

ASP.NET web application on a shared host. 
How can I find the outgoing IP address of a web application from within the app? In other words, via code.

It is needed to whitelist the server for calls to a remote SQL Server. I've usedHttpContext.Current.Request.ServerVariables("LOCAL_ADDR"). However, the web host tells me to use a call to an external site like ipecho.net, which sometimes returns a different IP.
Could someone explain why sometimes the two methods have a different result? Which would be correct?

How can I rotate a bitmap, keeping its scale

$
0
0

Hi all;

I'm trying to rotate a bitmap where I retain all the pixels, and the destination bitmap size is set so that I get it at the same scale. In other words, every pixel in the source is a distinct pixel in the output, and the output bitmap size adjusts to match.

I've tried a bunch of stuff (below code here in a zip with bitmap files). But what I'm getting is partial images in the output, and in some cases, scaled down.

using System;
using System.IO;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

namespace RotateBitmap
{
	class Program
	{
		static void Main(string[] args)
		{
			RotateBitmap("cows.png", "cows_rotated.png", 90);
			RotateBitmap("zoey.jpeg", "zoey_rotated.png", 45);
		}

		static void RotateBitmap(string srcFilename, string destFilename, double degrees)
		{

			srcFilename = Path.GetFullPath(Path.Combine("../..", srcFilename));
			destFilename = Path.GetFullPath(Path.Combine("../..", destFilename));
			byte[] data = File.ReadAllBytes(srcFilename);
			MemoryStream stream = new MemoryStream(data);
			Bitmap srcBitmap = new Bitmap(stream);

			double radians = Math.PI * degrees / 180;

			double sin = Math.Abs(Math.Sin(radians)), cos = Math.Abs(Math.Cos(radians));
			int srcWidth = srcBitmap.Width;
			int srcHeight = srcBitmap.Height;
			int rotatedWidth = (int)Math.Floor(srcWidth * cos + srcHeight * sin);
			int rotatedHeight = (int)Math.Floor(srcHeight * cos + srcWidth * sin);

			Bitmap rotatedImage = new Bitmap(rotatedWidth, rotatedHeight);
			Graphics g = Graphics.FromImage(rotatedImage);
			g.InterpolationMode = InterpolationMode.HighQualityBicubic;
			g.PixelOffsetMode = PixelOffsetMode.HighQuality;
			g.SmoothingMode = SmoothingMode.HighQuality;

			// Set the rotation point to the center in the matrix
			g.TranslateTransform(rotatedWidth / 2, rotatedHeight / 2);
			// Rotate
			g.RotateTransform((float)degrees);
			// Restore rotation point in the matrix
			g.TranslateTransform(-srcWidth / 2, -rotatedHeight / 2);
			// Draw the image on the bitmap
			g.DrawImage(srcBitmap, 0, 0);

			srcBitmap.Dispose();
			g.Dispose();

			stream.Close();
			stream = new MemoryStream();
			rotatedImage.Save(stream, ImageFormat.Png);
			data = stream.ToArray();
			File.WriteAllBytes(destFilename, data);
		}
	}
}

Any ideas?

thanks - dave


What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

clr.dll error cause stop my service

$
0
0

I made a windows service project named "WindowsService-DS".

Then I run it on more than one computer. Then some of them will stop my service with an error, the error modle is "clr.dll" and error code is "c0000005".

It is strange that only three computer have the error. And I can only find "ntdll.dll" error from the system dump file. I have tryied to  restore donet library,but it is not work. "clr.dll" file version is 4.0.30319.17929

It have occured 5 times on three computer, and i have no idea. 

Look forward to your reply

How to consistently check if running window is obscured by other windows?

$
0
0

I have the following code to determine if something is covering my app's window:

public static bool IsOverlapped(Window window)
{
    var hWnd = new WindowInteropHelper(window).Handle;
    if (hWnd == IntPtr.Zero)
        throw new InvalidOperationException("");
    if (!IsWindowVisible(hWnd))
        return false;

    HashSet<IntPtr> visited = new HashSet<IntPtr> { hWnd };

    RECT thisRect;
    GetWindowRect(hWnd, out thisRect);

    while ((hWnd = GetWindow(hWnd, GW_HWNDPREV)) != IntPtr.Zero && !visited.Contains(hWnd))
    {
        visited.Add(hWnd);
        RECT testRect, intersection;
        if (IsWindowVisible(hWnd) && GetWindowRect(hWnd, out testRect) && IntersectRect(out intersection, ref thisRect, ref testRect))
            return true;
    }

    return false;
}

It works great except for a couple edge cases. These edge cases being:

  1. Sometimes when computer is switching users or is put to sleep, and then signing back in
  2. Whenever switching virtual desktops on Windows 10.

I managed to solve scenario 2 by using the IVirtualDesktopManager to physically move the window, but this all fails whenever scenario 1 occurs.

The only way I noticed to get it working again is to have the user physically click on the window, which is less than ideal. Even trying to programmically focus or activate the window does not work. Any ideas how to fix?

Why is this code not pulling from the WOW6432Node node in the registry?

$
0
0

Hi all;

I have an anyCpu app that's an AddIn for Office. As such, it is running in 32-bit mode on my syste as I have 32-bit Office. The following code is not using the WOW6432Node in the registry;

using (RegistryKey keyLic = Registry.LocalMachine.OpenSubKey("Software\\Windward Studios\\Auto Tag"))

I know it's not because on creating it creates it in "HKLM\Software\Windward Studios\Auto Tag" and on reading it it gets the value in "HKLM\Software\Windward Studios\Auto Tag". There is no "HKLM\Software\WOW6432None\Windward Studios" node in the registry.

And to be double sure - I just did a evaluate of IntPtr.Size in the debugger. It returns 4.

??? - thanks - dave


What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

regarding AD connection

$
0
0

Hi there,

I attempt to access Active Directory by code but the error message "The server is not operational." always comes up. my simple code is like the following:

var ldapPath = "dev.foo.hksarg:389"; // domain is DEVFOO

            using (DirectoryEntry directoryEntry = new DirectoryEntry("LDAP://" + ldapPath, "DEVFOO\\DEVAdmin", "P@ssw0rd", AuthenticationTypes.None))
            {
                using (DirectorySearcher directorySearcher = new DirectorySearcher(directoryEntry))
                {
                    directorySearcher.PropertiesToLoad.AddRange(_properties);

                    if (account.Contains('@')) directorySearcher.Filter = "(userPrincipalName=" + account + ")";
                    else directorySearcher.Filter = "(samAccountName=" + account + ")";                    var user = directorySearcher.FindOne().GetDirectoryEntry();
                    Console.WriteLine(GetDomain.ldap_get_value<string>(user.Properties["displayName"]));
                    Console.WriteLine(GetDomain.ldap_get_domainname(user));
                    Console.WriteLine(GetDomain.ldap_get_domainname(user) + "\\" + GetDomain.ldap_get_value<string>(user.Properties["samAccountName"]));

                    Console.ReadLine();
                }
            }

this line "var user = directorySearcher.FindOne().GetDirectoryEntry();" --> error; actually I found the "directoryEntry" is null

so does anyone have ideas on it??

Thanks

Active Directory: how to get current domain

$
0
0

Hi there,

My scenario is there is a user in the AD OU container and there are two UPN (User logon name) along with this account. for example:

  1. my ldap: dev.local
  2. my domain: devlocal
  3. my user account: aaronp
  4. my user account (user logon name): aaronp@dev.local and aaronp@dev.com.my

my question is how to convert UPN format to devlocal\aaronp, when user uses the UPN format to login certain system even if the format are aaronp@dev.local and aaronp@dev.com.my. finally I could get the devlocal\aaronp

  • aaronp@dev.local --> devlocal\aaronp
  • aaronp@dev.com.my --> devlocal\aaronp

Thanks


Hi there, if you found my comment very helpful then please | Propose as answer | . Thanks and Regards.


how to remve listview items gap

$
0
0

hi

i'm trying to create report page (something like image2) and i'm trying to use ListView which allows me easily add/remove table rows and also allows to use table rows as custom control.

the problem is listview items alway separated by little vertical space (imgae1), 

my question is how to get rid of this space?

.Net Core 3.1 Generic host

$
0
0
Having a generic host which is built and run from a consoles Main method.
One hosted service is added, having dependencies of other singleton services.
One of these singleton services gets serious problem during construction and want to shutdown the console program or cancel the hosted service CancelletionTokenSource, how can this be done?

PageUp and PageDown in DataGridView not going to FormKeyDown

$
0
0

Hello all. I have a TabControl with DataGridViews on some of the TabPages. Users want to hit PageUp and PageDown keys to change tab indexes no matter where the focus is. This is implemented in Form_KeyDown() with Keypreview=true. It works if the focus is on a TextBox.

But if the focus is on a DataGridView, PageUp and PageDown skip Form_KeyDown() and go straight to DataGridView and change the grid row indicator. This is not what the users want.

I tried to use a.Handled=true and send the same key to the hosting form. but they even skip DataGridView_KeyDown().

Any idea ? Thanks.

How to convert MS XLS to vCard

Console app with generic host, strange message order

$
0
0

.Net Core 3.1

Console app with generic host and serilog.

"Application started" message is shown after messages from my hosted service and it looks a bit "messy".
Possible to finish the "app pipeline" before starting the service?

compilation error in converting .net framework to .net standard dll

$
0
0
We converted class library from .net framework to .net standard 2.0
Project A conosle app in .net framework 4.6.2 starts complaining. which uses the above library.

SeverityCode DescriptionProjectFileLineSuppression State
ErrorCS0433 The type 'XmlElementAttribute' exists in both 'System.Xml.XmlSerializer, Version=4.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
SeverityCode DescriptionProjectFileLineSuppression State
ErrorCS0433 The type 'ConcurrentDictionary<TKey, TValue>' exists in both 'System.Collections.Concurrent, Version=4.0.13.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
SeverityCode DescriptionProjectFileLineSuppression State
ErrorCS0433 The type 'ConfigurationManager' exists in both 'System.Configuration.ConfigurationManager, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' and 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'


I tried adding nuget of Microsoft.Windows.Compatibility to console app but it doesn't help.
console app had reference to both System.Configuration.dll and system.configuration.configurationManager nuget.

SignalR SSE blocked

$
0
0

Hi,

not sure if this is the right place for this topic. 

We have an implementation of our software that uses SignalR, does anyone know what could block Server Sent Events from working?

Normally it would try the following in that order: WebSockets, Server Sent Events, Long Polling. WebSockets are not available since our customer has a Load Balancer with SSL offloading and other Security services we think. We'd be fine to use SSE for now.

However the first SSE call goes in a timeout after 5 seconds and then it falls back to long polling. The only issue we have is that we loose 5 seconds (its a time critical application).

Implementation works with SSE in another environment. 


Regards

Daniel

MCSE - MCSA - MCP - MS - Security+ - Network+

Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.


test in 01

Look for bound DLLs in folder the calling DLL is in (Office AddIn)

$
0
0

Hi all;

I have an Office AddIn and it is bound to DevExpress.Data.v18.2.DLL. However, it is not finding it. This file is in the same folder that my AddIn dll is in. But according to FusLog, it doesn't look there. This is for the case of running under the VisualStudio debugger.

FusLog reports:

===Pre-bind state information ===
LOG:DisplayName=DevExpress.Data.v18.2,Version=18.2.7.0,Culture=neutral,PublicKeyToken=b88d1754d700e49a(Fully-specified)
LOG:Appbase= file:///C:/Program Files (x86)/Microsoft Office/root/Office16/
LOG:InitialPrivatePath= NULL
LOG:DynamicBase= NULL
LOG:CacheBase= NULL
LOG:AppName= POWERPNT.EXECalling assembly :(Unknown).===
LOG:This bind starts indefault load context.
LOG:No application configuration file found.
LOG:Using host configuration file:
LOG:Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: GAC Lookup was unsuccessful.
LOG:Attempting download ofnew URL file:///C:/Program Files (x86)/Microsoft Office/root/Office16/DevExpress.Data.v18.2.DLL.
LOG:Attempting download ofnew URL file:///C:/Program Files (x86)/Microsoft Office/root/Office16/DevExpress.Data.v18.2/DevExpress.Data.v18.2.DLL.
LOG:Attempting download ofnew URL file:///C:/Program Files (x86)/Microsoft Office/root/Office16/DevExpress.Data.v18.2.EXE.
LOG:Attempting download ofnew URL file:///C:/Program Files (x86)/Microsoft Office/root/Office16/DevExpress.Data.v18.2/DevExpress.Data.v18.2.EXE.
LOG:All probing URLs attempted and failed.

How can I get it to also look in the folder my AddIn DLL is in?

thanks - dave


What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

FatalExecutionEngineError when accessing user control

$
0
0

Hi there, 

I had encounter an exception both in .Net 4.6.2 .Net 4.7.1 with WPF project.

Managed Debugging Assistant 'FatalExecutionEngineError' 
The runtime has encountered a fatal error. The address of the error was at 0x13471594, on thread 0x3d78. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

An unhandled exception of type 'System.ExecutionEngineException' occurred in WindowsBase.dll

The program '[0x4ECC] McuSDKTesttool.exe: Program Trace' has exited with code 0 (0x0).
The program '[0x4ECC] McuSDKTesttool.exe' has exited with code -2146233082 (0x80131506).

source code is very simple when accessing usercontrol after. Can you help to check? and tell me where can i upload source code and dump file. Many thanks :)

Roger

Console app with generic host, strange message order

$
0
0

.Net Core 3.1

Console app with generic host and serilog.

"Application started" message is shown after messages from my hosted service and it looks a bit "messy".
Possible to finish the "app pipeline" before starting the service?

Need to focus the grid which placed inside the Scroll Viewer on Mouse Click

$
0
0

Problem 1:

 

I need to focus the Grid(UI Element) when it is placed inside the Scroll viewer.

Code:
```
  <ScrollViewer>
        <Grid x:Name="RootGrid">
            <Border 
                    Height="24"
                    Width="300"
                    Focusable="True"
                    Background="White"
                    BorderBrush="Silver"
                    BorderThickness="1"
                    SnapsToDevicePixels="True">
                <Grid Background="Red" Focusable="True" x:Name="ViewGrid">
                </Grid>
            </Border>
        </Grid>
    </ScrollViewer>
```


Problem Faced:

1.When I click the above control, scroll viewer is the focused element but i need Grid element needs to focused.
Please suggest solution to fix this.

Problem 2:

I have custom control. There is an unwanted white space was shown between border and grid in higher scaling like 125, 150 etc.,

Code

```
      <Grid x:Name="RootGrid">
            <Border 
                    Height="24"
                    Width="300"
                    Focusable="True"
                    Background="White"
                    BorderBrush="Silver"
                    BorderThickness="1"
                    SnapsToDevicePixels="True">
                <Grid Background="Red" Focusable="True" x:Name="ViewGrid">
                </Grid>
            </Border>
        </Grid>
    </ScrollViewer
```
Image:





Please suggest solution to resolve this.


  



Viewing all 8156 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>