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

WCF service cannot reference a UWP class library

$
0
0

Hi,

Recently I have been trying to make a UWP version of a sample WPF Interface program written by Jeremy Clark (https://github.com/jeremybytes/learning-interfaces).

In my program, I am using "UWP Class Library" instead of ".NET Framework Class Library". While I am able to reference a WCF service from UWP class library, I am getting an error when I am trying to reference the UWP class library from the WCF service. The exact error message I am getting is "Unable to add reference to project".

Next, I replaced all UWP class library to .NET Framework class library. Now I could reference it from the WCF service. However, now I cannot reference the .NET class library from a UWP blank app.

I even tried using ".NET Standard Class Library". However, calling a service reference from it creates a very different ServiceClient class with some standard methods like GetData() missing from the class.

I would like to use UWP Class Library. Kindly suggest a way in which I could reference it from WCF service.

 


Silver light in 64 bit Mode

$
0
0
Is there any way to migrate silver light 32 bit application to 64 bit as MAC not support 32 bit? Please help me any boy. Thanks. 

Are ICryptoTransform.TransformBlock() and SHA256.ComputeHash() methods thread-safe?

$
0
0

Are ICryptoTransform.TransformBlock() and SHA256.ComputeHash() methods thread-safe?

I call System.Security.Cryptography.Aes.Create() to create an instance, then I call CreateEncryptor() / CreateDecryptor(). Can I useICryptoTransform.TransformBlock() method of these objects by multiple threads? Do I need mutual exclusive access? I see that creating of these objects is expensive.

The same question is about System.Security.Cryptography.SHA256.ComputeHash() method. Is it thread-safe?

Cannot connect to a FTPS(SSL/TLS) server

$
0
0

Hello all. I have spent a day long trying to figure out why I could not connect to a FTPS server but to no avail. I always got this error.

System.Security.Authentication.AuthenticationException
a call to SSPI failed, see inner exception

I set up a connection in FileZilla, with protocal=FTP and encription=any of the three TLS choices. It works well. I can download, upload and delete files in the server. But it just doesn't work with C# code.

Does anyone have any ideas ?

public bool CheckConnection(string RemoteHost, string UserName, string Password)
{
     try
     {
        FtpWebRequest request = (FtpWebRequest)WebRequest.Create(RemoteHost);
        request.EnableSsl = true;
        request.Method = WebRequestMethods.Ftp.ListDirectory;
        request.Credentials = new NetworkCredential(UserName, Password);             
        request.GetResponse();
      }
        catch (WebException ex)
      {
         MessageBox.Show("Fail:" + ex.ToString());
          return false;
      }
       return true;
}



Math.Pow() function is giving different result

$
0
0

I'm using Math.Pow functions in my C# code and it's giving me different results on two of my machines. The code and input it using are the same but still, the method yields a different result. I've dug further and found that that the .net framework is different on my machine . it is 4.7.03190 and 4.8.03761 on other.  Is this because of framework? or becasue of CLR?

though the clr version seems to same on both of my machine

Data Overlay onto a predefined form/document layout design and generate pdf c#

$
0
0

Hi,

I am trying to find a solution for my scenario and not sure if there is any built in feature or library or how to do it.

Scenario:

I have an external system which sends a .TXT file in a well formatted or pre defined formatted text data spaced to a page size.

Eg: 

"Title                                                                       06/17/2020.          emailaddressdata

Data1                     Data2                           Data3

            Data4                                                                       XX

                                                                                                       autogen doc.          *"

Something like that. And I need to put the data onto a form(overlay) which has the details/designed like header, labels etc. and then convert into pdf file.

Current solution I developed is:

I used a windows application and I added and designed a report RDLC form with fields and headings, lines etc, and placed a textbook and at runtime giving the data -above formatted data from input txt file and it overlays perfectly onto it and even the report had render option to create a pdf.

Now the problem is I don't know if it is the right approach and also it doesn't work for multi page thing. I mean the input data can have data related to 1 page or multi page spaced correctly according to document or page size(A4 paper). when overplayed, the form design is applied only to the page 1 as I designed it only 1 page rdlc form.

with my current approach, I cannot keep designing rdlc forms all the way till 1000 pages. I want a dynamic solution and at the end I need to have a pdf files with 1 to 1000 pages (it can be n pages).

 

Thank you very much, you are help os much appreciated.



Merge pdf files into 1 pdf c#

$
0
0

Hi,

Does DOTNET provide any built in library or technique to merge multiple pdf files into 1 files with out using any 3rd party pdf libraries.

Thank you.

Cannot connect to a FTPS(SSL/TLS) server

$
0
0

Hello all. I have spent a day long trying to figure out why I could not connect to a FTPS server but to no avail. I always got this error.

System.Security.Authentication.AuthenticationException
a call to SSPI failed, see inner exception

I set up a connection in FileZilla, with protocal=FTP and encription=any of the three TLS choices. It works well. I can download, upload and delete files in the server. But it just doesn't work with C# code.

Does anyone have any ideas ?

public bool CheckConnection(string RemoteHost, string UserName, string Password)
{
     try
     {
        FtpWebRequest request = (FtpWebRequest)WebRequest.Create(RemoteHost);
        request.EnableSsl = true;
        request.Method = WebRequestMethods.Ftp.ListDirectory;
        request.Credentials = new NetworkCredential(UserName, Password);             
        request.GetResponse();
      }
        catch (WebException ex)
      {
         MessageBox.Show("Fail:" + ex.ToString());
          return false;
      }
       return true;
}




Web API - Authenticate users using Azure AD SAML Protocol without being redirect to Microsoft Login Page

$
0
0

It's my first time with Azure AD and SAML protocol, I want to know if it's possible to add a user authentication request to Azure AD without being redirecting to Microsoft Login Page? If so, how it can be done?

Basically, I want to send the email and password and authenticate to Azure without leaving the page of my Mobile application.

Wireshark Tool

$
0
0

Hi Team,

I am using wireshark tool to capture network packet is this right place to post if not please suggest

MBOX to PST Converter

$
0
0

KDETools MBOX to PST Converter software that allows you to convert MBOX files to PST format without precision. With this tool you can even convert MBOX files to other formats like EML, EMLX, HTML, MSG. The software enables the creation of more than 20 email clients such as Entourage, Google Takeout, Netscape, SeaMonkey etc. The user can easily import MBOX files into Outlook 2019, 2016, 2013, 2010, 2007, 2003 etc.


Convert MBOX to PST file format

$
0
0
The KDETools MBOX to PST converter tool offers a simple, secure and fast conversion solution for converting MBOX to PST. This software has a function for saving converted MBOX files in various formats such as PST, EML, MSG, EMLX, HTML. This software also shows the preview of all emails before saving. The application offers a unique feature sharing feature that allows PST files to be used by size (1GB to 10GB).


migration of 4.5 to 4.8 framework

$
0
0

Hi Team,

I am doing migration asp.net project 4.5 framework 4.8

While giving build observed that reference  missing system.runtime.dll and if i add this dll to all class library build is success

what system.runtime.dll does exactly

any suggestion and help will be highly appreciated on how to proceed further on this.
Regards

System.Data.IDataReader performing slow

$
0
0

Hello All,

I am using following lines of code to Retrive data from database  :

while (IDataReaderObject.Read())
{
}

there are only about 4000 records and 4 columns and this blank loop is taking about 1 to 1.30 min. to execute...

can any one help me for this ??????

data is in following format :

Col1      Col2          Col3        Col4

----------------------------------------

A          D17081    38.17       98.42
A          D18252    20.70       99.47
A          D16141    52.82         0.00

UWP Windows 10 1909 BLE Connecting Without Pairing

$
0
0


My Goal: Connect to a BLE device without manually selecting the pair device popup ie use "Just Works" ble connectivity option.

To verify that the problem is not on the BLE device side I confirmed that I can connect to the BLE device with the 'Just Works' option through the NRF connect app on Android, and on iOS.

Some info about my setup and things I have done so far:

I have Bluetooth capabilities enabled in the Manifest. I have tested that bluetooth works when pairing directly with a separate device that uses BLE such as some headphones. I have made sure that Bluetooth is turned on. I can connect to my BLE device when I used the pairing option however it displays a popup each time and I don't want that popup, I want it to just work without any interaction. When PairAsync is not used the result of FromBluetoothAddressAsync or FromIdAsync is 'Disconnected'. I am using Windows 10 1909 18363.900. I should note that this used to work on 1803. All of my bluetooth drivers are up to date. I tried this on another laptop and it did not work without the pairing popup also.

Here is my code:

private string DEVICE_ADDRESS_TEST = "C7:9C:0C:EE:EA:D1";
        // Create BLE watcher
        var bleWatcher = new BluetoothLEAdvertisementWatcher() { ScanningMode = BluetoothLEScanningMode.Active };

        // add received callback
        bleWatcher.Received += async (BluetoothLEAdvertisementWatcher w, BluetoothLEAdvertisementReceivedEventArgs btAdv) => {
            try
            {
                /// SCAN FIND DEVICE
                ulong longAgain = ulong.Parse(this.DEVICE_ADDRESS_TEST.Replace(":", ""), System.Globalization.NumberStyles.HexNumber);
                if (btAdv.BluetoothAddress != longAgain)
                {
                    Logging.info($"Found device: {btAdv.BluetoothAddress}");
                    return;
                }
                else
                {
                    Logging.info($"Found BLE device [{DEVICE_ADDRESS_TEST}]");
                    bleWatcher.Stop();
                }

                // This causes a popup to appear! I don't want this.
                //DevicePairingResult result = await di.Pairing.PairAsync(DevicePairingProtectionLevel.Encryption); 
                // This causes a popup to appear! I don't want this.
                //DevicePairingResult result = await di.Pairing.PairAsync(DevicePairingProtectionLevel.None); 

                /// CONNECT TO DEVICE
                Logging.info("Connecting...");
                var device = await BluetoothLEDevice.FromBluetoothAddressAsync(longAgain);


                var log1 = $"Connection state: [{device.ConnectionStatus}]";
                Logging.info(log1);
                if (device.ConnectionStatus != BluetoothConnectionStatus.Connected)
                {
                    throw new Exception("FromBluetoothAddressAsync did not connect successfully.");
                }

                /// GET ALL SERVICES
                Logging.info("Getting services..");
                // 2) SERVICES!!
                var result = await device.GetGattServicesAsync();

                if (result.Status != GattCommunicationStatus.Success)
                {
                    throw new Exception($"GetGattServicesAsync failed with result: status[{result.Status}], error[{result.ProtocolError}]");
                }

                Logging.info($"[{result.Services.Count}] services found");
            }
            catch (Exception e)
            {
                Logging.error(e.Message);
            }

        };
        bleWatcher.Start();

What am I doing wrong? There has to be a way to connect to devices without needing to interact with a popup. Is there a new API I am missing? Please help!

UPDATES:

I found that performing a GetGattServicesForUuidAsync or GetGattServicesAsync results in the device connecting however they both return the status 'Unreachable'. This is odd because I can see a light that denotes if a device is connected or not. Again I have to reiterate that this behavior is only on the window platform as I can easily connect and get services using the 'just workings' on android and ios.


migration of 4.5 to 4.8 framework

$
0
0

Hi Team,

I am doing migration asp.net project 4.5 framework 4.8

While giving build observed that reference  missing system.runtime.dll and if i add this dll to all class library build is success

what system.runtime.dll does exactly

any suggestion and help will be highly appreciated on how to proceed further on this.
Regards

Azure portal works very slow

$
0
0

Hi All,

I want to change subscription on my resources in azure portal.

I'm trying to do this for 2 days. App Service is not opening.

What should I do? Where can I report it? I don't need payable support for one simple page.

Thanks,

Michal

Alternate for ApplicationBlocks.ExceptionManager in .NET Core

$
0
0

I am migrating code from .net 4.6.2 to .net core/.net standard 2.2.

I am trying to find alternate for ExceptionManager.Publish() in .net core.

My current code is like below :

using Microsoft.ApplicationBlocks.ExceptionManagement;

          Exception e = new Exception(strMessage);

         ExceptionManager.Publish(e, objLogInfo);

And in Config we are specifying where exactly to log the event

<publishermode="on"assembly="Microsoft.ApplicationBlocks.ExceptionManagement"type="Microsoft.ApplicationBlocks.ExceptionManagement.DefaultPublisher"     logname="myLog"applicationname="myasmx" />

I used  nugets like - EnterpriseLibrary.ExceptionHandling 6.0.1.3  & EnterpriseLibrary.ExceptionHandling.netcore 6.3.0

is there any support for ApplicationBlocks.ExceptionManager .net core? Please help me out in fixing it.

ERROR 0x0070422

How to code a .Net Class which uses Win32 IShellLink to handle shortcuts (links)

$
0
0

Hi all,

after reading piles of docs I have still no idea how to code a .Net Class which uses Interop to exercise COM IShellLink methods. My intend is to use VS 2017 to generate an IShellLink assembly by referencing SHELL32.dll and use the the Interfaces as usual. I could not fin any example, which shows the necessary steps. Here is my WIN32 code I have scribbled to show my intend:

//*-------------------------------------------------------------------------------------*
//	Class for safe handler instantiation. This class is instantiated as the first
//	statement into the variable coInit. During exit-processing coInit is destroyed by
//	calling its destructor, which inturn issues CoUninitialize.
//*-------------------------------------------------------------------------------------*

class CCoInitialize {
	public:
		CCoInitialize( ) : m_hr( CoInitialize( NULL ) ) {}
		~CCoInitialize( ) { if (SUCCEEDED( m_hr )) CoUninitialize( ); }
		operator HRESULT( ) const { return m_hr; }
		HRESULT m_hr;
	};

//*-------------------------------------------------------------------------------------* // This is the function that instantiates IShellLink and deserialzes the shortcut
// to have access to its content. Two methods of IShellLink are used to get the
// path to the referenced file dun the description contained in the shortcut. //*-------------------------------------------------------------------------------------*

HRESULT GetPathFromLink(LPCWSTR lpszLinkFile, LPWSTR lpszPath, LPWSTR lpszDescription, int iPathBufferSize, LPWSTR lpszErrorSource ) {
	HRESULT hres;
	IShellLink* psl = 0;
	IPersistFile* ppf = 0;
	WCHAR szGotPath[(MAX_PATH + 1)];
	WIN32_FIND_DATA wfd;
	WCHAR szDescription[(MAX_PATH + 1)];
	WCHAR szErrorSource[(MAX_PATH + 1)];

	*lpszPath = 0; *lpszDescription = 0;

	// Get a pointer to the IShellLink interface. It is assumed that CoInitialize	has already been called.
	//
	StringCbCopy( szErrorSource, iPathBufferSize, L"CoCreateInstance" );
	hres = CoCreateInstance( CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl );
	if (SUCCEEDED( hres )) {
		StringCbCopy( szErrorSource, iPathBufferSize, L"Get IPersistFile" );
		hres = psl->QueryInterface( IID_IPersistFile, (void**)&ppf );
		if (SUCCEEDED( hres )) {
			StringCbCopy( szErrorSource, iPathBufferSize, L"Load Linkfile" );
			hres = ppf->Load( lpszLinkFile, STGM_READ );														// Load the shortcut into instance
			if (SUCCEEDED( hres )) {
				StringCbCopy( szErrorSource, iPathBufferSize, L"Get Path from Link" );
				hres = psl->GetPath( szGotPath, MAX_PATH, (WIN32_FIND_DATA*)&wfd, 0 );
				if (SUCCEEDED( hres )) {
					StringCbCopy( szErrorSource, iPathBufferSize, L"Get Description from Link" );
					hres = psl->GetDescription( szDescription, MAX_PATH );
					if (SUCCEEDED( hres )) {
						StringCbCopy( szErrorSource, iPathBufferSize, L"Copy Path to Caller" );
						hres = StringCbCopy( lpszPath, iPathBufferSize, szGotPath );
						if (SUCCEEDED( hres )) {
							StringCbCopy( szErrorSource, iPathBufferSize, L"Copy Description to Caller" );
							hres = StringCbCopy( lpszDescription, iPathBufferSize, szDescription );
							StringCbCopy( lpszErrorSource, iPathBufferSize, L"");
							}
						else {
							}
						}
					}
				}			
			}
		}
	if (ppf != 0) 	ppf->Release( );	
	if (psl != 0) 	psl->Release( );
	return hres;
}

Any help how to get a hand on coding this in .Net using the generated assembly from SHELL32.dll is appreciated.

TIA :-)


Regards Jörg





Viewing all 8156 articles
Browse latest View live


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