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

ParallelFor bug

$
0
0

Prepare a static class, with a static property, static method, and a static constructor, then the bug comes:

public class ParallelForBug
{
    public static string StaticProperty = "StaticProperty";

    static void method(int i)
    {
        Console.WriteLine("null method: " + i);
    }

    static ParallelForBug()
    {
        Parallel.For(0, 10, i => {
            Console.WriteLine(i);
            method(i);
        });

    }
}

call the property.

    static void Main(string[] args)
    {
        string str = ParallelForBug.StaticProperty;
        Console.WriteLine(str);            
    }

You will never saw what the str is. Is this a bug, or just I miss anything.


Mike Feng
Help me, help you


Microsoft Graph -Insufficient enterprise tenant permissions, cannot access this API.

$
0
0

All,

I'm receiving the following error when trying to create a call bot that calls Microsoft Graph API.

I have added all of the following permissions:

Calls.JoinGroupCallAsGuest.All
<button aria-controls="flyout3" aria-expanded="false" aria-label="more option menu" class="f1enh5kk" role="button" style="background-image:none;background-background-size:initial;background-repeat:initial;background-attachment:initial;background-origin:initial;background-clip:initial;border-width:0px;border-style:initial;border-color:initial;cursor:pointer;font:inherit;height:2.28571rem;outline:none;width:2.28571rem;"></button>
Calls.JoinGroupCall.All
<button aria-controls="flyout4" aria-expanded="false" aria-label="more option menu" class="f1enh5kk" role="button" style="background-image:none;background-background-size:initial;background-repeat:initial;background-attachment:initial;background-origin:initial;background-clip:initial;border-width:0px;border-style:initial;border-color:initial;cursor:pointer;font:inherit;height:2.28571rem;outline:none;width:2.28571rem;"></button>
Calls.InitiateGroupCall.All
<button aria-controls="flyout5" aria-expanded="false" aria-label="more option menu" class="f1enh5kk" role="button" style="background-image:none;background-background-size:initial;background-repeat:initial;background-attachment:initial;background-origin:initial;background-clip:initial;border-width:0px;border-style:initial;border-color:initial;cursor:pointer;font:inherit;height:2.28571rem;outline:none;width:2.28571rem;"></button>
Calls.Initiate.All
<button aria-controls="flyout6" aria-expanded="false" aria-label="more option menu" class="f1enh5kk" role="button" style="background-image:none;background-background-size:initial;background-repeat:initial;background-attachment:initial;background-origin:initial;background-clip:initial;border-width:0px;border-style:initial;border-color:initial;cursor:pointer;font:inherit;height:2.28571rem;outline:none;width:2.28571rem;"></button>
Calls.AccessMedia.All
<button aria-controls="flyout7" aria-expanded="false" aria-label="more option menu" class="f1enh5kk" role="button" style="background-image:none;background-background-size:initial;background-repeat:initial;background-attachment:initial;background-origin:initial;background-clip:initial;border-width:0px;border-style:initial;border-color:initial;cursor:pointer;font:inherit;height:2.28571rem;outline:none;width:2.28571rem;"></button>
CallRecords.Read.All

fail: VoiceRecorderAndPlaybackBot[1742746998]
      2020-07-06T23:05:11.5197Z 00000000-0000-0000-0000-000000000000 pid:23658 tid:47 (Bot.cs:247 NotificationProcessor_OnNotificationReceived):
      Caught an Exception running the task: Error processing notification /communications/calls/be1f0400-731f-489a-a110-5457d9a040c8 with scenario e5b6e28c-e545-4638-8f32-d8ff8a4e8fbf
      exception: Code: 7504
      Message: Insufficient enterprise tenant permissions, cannot access this API.
      Inner error:
AdditionalData:
date: 2020-07-06T23:05:11
request-id: 2df32658-90f2-4b97-a39e-5f18ed3d2063

      StackTrace:    at Microsoft.Graph.Communications.Client.Transport.GraphAuthClient.ValidateResponseAsync(HttpResponseMessage response)
         at Microsoft.Graph.Communications.Client.Transport.GraphAuthClient.SendHttpRequestAsync[T1,T2](IGraphRequest`1 graphRequest, CancellationToken cancellationToken)
         at Sample.Common.Transport.GraphClientExtensions.SendAsync[T](IGraphClient client, IBaseRequest request, RequestType requestType, String tenant, Guid scenarioId, CancellationToken cancellationToken) in /Users/benjaminharvey/Desktop/microsoft-graph-comms-samples-master/Samples/Common/Sample.Common/Transport/GraphClientExtensions.cs:line 107
         at Sample.VoiceRecorderAndPlaybackBot.Bot.Bot.BotRecordsIncomingCallAsync(String callId, String tenantId, Guid scenarioId) in /Users/benjaminharvey/Desktop/microsoft-graph-comms-samples-master/Samples/V1.0Samples/StatelessSamples/VoiceRecorderAndPlaybackBot/Bot/Bot.cs:line 456
         at Sample.VoiceRecorderAndPlaybackBot.Bot.Bot.NotificationProcessor_OnNotificationReceivedAsync(NotificationEventArgs args) in /Users/benjaminharvey/Desktop/microsoft-graph-comms-samples-master/Samples/V1.0Samples/StatelessSamples/VoiceRecorderAndPlaybackBot/Bot/Bot.cs:line 310
         at Sample.Common.CommonUtilities.ForgetAndLogExceptionAsync(Task task, IGraphLogger logger, String description, String memberName, String filePath, Int32 lineNumber) in /Users/benjaminharvey/Desktop/microsoft-graph-comms-samples-master/Samples/Common/Sample.Common/CommonUtilities.cs:line 40

                                    <link href="https://kit-free.fontawesome.com/releases/latest/css/free.min.css" media="all" rel="stylesheet" /><iframe frameborder="none" id="sidePane" src="chrome-extension://egdlmbioafdidbljnampdodjfnfjbpic/popup.html?url=https://social.msdn.microsoft.com/Forums/en-US/newthread?forum=WindowsAzureAD" style="height:100%;width:0px;;top:0px;right:0px;z-index:2147483647;"></iframe>

.NET Core Console app: Read list of blobs as read-only user

$
0
0

I have a problem, which I cannot figure out to solve:

Our company has appr. 20 Azure storage accounts with appr. 20 containers each. I want to write a .NET Core console application, which I can run on a (non-Azure) Windows server for backing up the blobs with read-only access.

If I would use the access keys, I would have the problems a) I would need 20 different access keys and b) the access keys are allowed for full access. With SAS, even worse, I would have appr. 400 different SAS keys.

Now: I created a new user, e. g. "backup@mycompany.com", which is a global reader - so no possibility to write/delete. I registered my application as a Windows application.

However, despite reading and trying out so many ways, I was not able to figure out how my console application can automatically log in through e. g. Azure Active Directory (password) with username + password (storing both e. g. in appsettings.json).

Can you provide .NET Core C# code how I can a) login and b) list all blobs in one storage account >> container?

Thanks so much!!

Martin

How to get a C++/CLI component to load into MEF?

$
0
0

Having seen the similar question https://social.msdn.microsoft.com/Forums/en-US/157dc66e-87a9-44bf-9de9-9fcdc6c95fea/ccli-how-to-translate-ltexportgettypeiplugingt?forum=netfxbcl here, I've double checked that all DLLs and the executable target the same processor type and framework version.  Looking at a C# component and the problematic C++/CLI component in ILSpy, I cannot discern a problem with the interface implementation and its attributes (other than one method being declared unsafe, because it uses for each).

Note the multiply on the left is written in C#, the divide on the right is written in C++/CLI

I loaded the assembly explicitly into the MEF catalog, but the ComposeParts extension method will not include the component written in C++/CLI into the component store.

I can upload the entire project if desired, it is based on the sample given in the MEF page of docs.microsoft.com.  

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

TLS 1.3 support

$
0
0

Hi Team,


I have migrated project from .net 4.5 to 4.8 framework could you please let us know is  TLS1.3 support available?

As i found mostly comments not supported so could you please let us know test cases to validate the same

i tried to captured logs when response and request happened but  i am getting default TLS 1.2 logs only ..

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

What is solution for the vulnerability CVE-2004-0847?

$
0
0

After running the OWASP Dependency checker for my ASP.net web application, I got a report says that Microsoft.Web.Infrasturucture.dll has a vulnerability CVE-2004-0847. What is the solution for this issue?

Thanks.



AxInterop doesn't generate

$
0
0

Back in VS2017, when referencing an OCX two files were created and referenced:

  • Interop.XYZLib.dll
  • AxInterop.XYZLib.dll

from there I was able to create a wrapper around AxInterop.XYZLib.dll that exposes the methods and properties of the OCX as if they are native. Now after installing VS2019 only Interop.XYZLib.dll is generated. Even if I go back to VS2017 the behavior is the same, only one is generated, and trying to use it causes a catastrophic failure. Other answers suggest to use AxImp.exe, I tried, only to have an error saying "Did not find a registered ActiveX control in ...", that's confusing since the OCX is registered with RegSvr32.exe, any ideas?

Thank you

Luis


Luis


Visual studio 2019 doesn't generate wrappers for Activex/OCX

$
0
0

Back in VS2017, when referencing an OCX two files were created and referenced:

  • Interop.XYZLib.dll
  • AxInterop.XYZLib.dll

from there I was able to create a wrapper around AxInterop.XYZLib.dll that exposes the methods and properties of the OCX as if they are native. Now after installing VS2019 only Interop.XYZLib.dll is generated. Even if I go back to VS2017 the behavior is the same, only one is generated, and trying to use it causes a catastrophic failure. Other answers suggest to use AxImp.exe, I tried, only to have an error saying "Did not find a registered ActiveX control in ...", that's confusing since the OCX is registered with RegSvr32.exe, any ideas?

Thank you

Luis


Luis


TLS 1.3 support

$
0
0

Hi Team,


I have migrated project from .net 4.5 to 4.8 framework could you please let us know is  TLS1.3 support available?

As i found mostly comments not supported so could you please let us know test cases to validate the same

i tried to captured logs when response and request happened but  i am getting default TLS 1.2 logs only ..

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

How to add desktop shortcut on installation of UWP app?

$
0
0
Upon installation, a shortcut does not get added to my Desktop, it gets added to start bar only. Is there any way I can add a shortcut to the desktop programmatically?

Unable to use AddSignIn Method of Microsoft.Identity.Web NuGet Package to acquire an AccessToken for Authorization Code Flow

$
0
0

We want to use MSAL for Authentication in our Web application with Web API using Authorization Code Flow.

I was using Sample from GitHub (https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/tree/master/4-WebApp-your-API/4-2-B2C). But unfortunately it uses Implicit Code Flow by default.

Note: I disabled both Access Token and Id Token from Implicit Flow option for the application on the Azure Portal.

As I can see in request URL for Authorization EndPoint, the ResponseType was "code id_token". But we just want to use Authorization Code Flow everywhere. So It needs to be "code" only.

Then I found in this StackOverflow Article (https://stackoverflow.com/questions/61554550/azure-ad-b2c-error-aadb2c90057-when-i-am-not-trying-to-use-the-implicit-flow) someone faced the same problem, I commented this line of code in Github sample
//services.AddSignIn(Configuration, "AzureAdB2C");

And added block of code from update section in StackOverflow Article (https://stackoverflow.com/questions/61554550/azure-ad-b2c-error-aadb2c90057-when-i-am-not-trying-to-use-the-implicit-flow).

Then I now get the following error:

Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectProtocolException: IDX21336: Both 'id_token' and 'access_token' should be present in OpenIdConnectProtocolValidationContext.ProtocolMessage received from Token Endpoint. Cannot process the message.

To fix it, I added "client id" scope to OpenIdConnectOptions according to this article (https://github.com/dotnet/aspnetcore/issues/23284#issuecomment-648775392)

Further, AcquireTokenByAuthorizationCode method was throwing a long exception with top line:

at Microsoft.Identity.Client.OAuth2.OAuth2Client.ThrowServerException(HttpResponse response, RequestContext requestContext)

I changed "Instance" in appsetting from https://company.b2clogin.com to https://company.b2clogin.com/tfp/.

Now I am getting Id Token, but AccessToken is returned null by AcquireTokenByAuthorizationCode method.


Am I still missing some configuration OR its some bug in Microsoft.Identity.Web with Authorization Code Flow?

Is it fine to use AddAuthentication with options for AzureADB2C(MSAL) OR We should be using AddSignIn Method only?







How to wait for a Serial Port to respond

$
0
0

Hi

Is it to possible to wait for a serialPort component to complete it's response? 

I have a device connected to the serial port of my PC. I use the serialPort component in order to communicate with the device. I have to send 2 different strings of data to the serial port but the trick is that after sending the first string of data I have to wait for the serial port to respond. Then I have to check the response and decide whether I must send the second string or not. Also after sending the second string, I have to check also the response of the serial port.

I tried to use an arbitrary amount of wait time between the sending of the two strings. Something like

SerialPort.Write(...) ; Thread.Sleep(2000); SerialPort.Write(...);

But the software failed when I tried it in a slower PC. So is there a way to replace the Thread.Sleep(2000) with a command that will wait until the serial port complete its response?

Although, the response of the serial port is different between the two sending strings, I do know that the first response is only one byte and I know the ending byte of the second response. Also, the second response is no more than 30 bytes in length.

Regards

Dimitris

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.



Adorner in WPF Textbox

$
0
0

I have created an adornerlayer over wpf textbox.

This code block will return the bounds of the text in textbox, i have written this block in onrender method of a adorner class.

Rect startPosition = textBox.GetRectFromCharacterIndex(startingCharOfAWord);
Rect endPosition = textBox.GetRectFromCharacterIndex(endingCharOfAWord,true);
Rect rectUnion = Rect.Union(startPosition, endPosition);

using this(rectPosition) position i can highlight the text in the textbox.

My Question : My textbox has more than 500 words. I need to scroll to read the text in the textbox. while scrolling in it, i used PreviewMouseWheel Event to update the adorner layer. But Rect returns empty. So i can't able get the bounds of the text.

Suggest me an idea to get Rect value of the text when scrolling the text in the texbox.


port

$
0
0
hi open me port25. Me need port25 for work with mail

[WPF] Opacity reverse not working while using DoubleAnimation

$
0
0

In my application I have two buttons and one textbox. 

In one button click I have set textbox opacity as 0 using DoubleAnimation using below code. 

private void Button_Click(object sender, RoutedEventArgs e)
        {
            var storyboard = new Storyboard();
            var opacityAnimation = new DoubleAnimation(0, TimeSpan.FromMilliseconds(167))
            {
                AutoReverse = false,
                EasingFunction = new SineEase { EasingMode = EasingMode.EaseOut }
            };
            Storyboard.SetTarget(opacityAnimation, textBox);
            Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath(UIElement.OpacityProperty));
            storyboard.Children.Add(opacityAnimation);
            storyboard.Begin();
        }

In next button click, I have set textbox opacity as 1 using Opacity property. 

 private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (textBox != null)
                textBox.Opacity = 1;
        }

But textbox not visible while setting opacity as 1. 

Xaml:

<TextBox Height="30" Width="152" 
                         x:Name="textBox" 
                         Text="Abc" Margin="20,0,0,0" /></StackPanel><Button Margin="5" Content="FadeTo" Width="100" Click="Button_Click"/><Button Margin="5" Content="Opacity-1" Width="100" Click="Button_Click_1"/></StackPanel>
Please help me. 



Thanks, Muneesh.

PrincipalContext exceptions ErrorCode

$
0
0

Hi,

I'm using PrincipalContext ValidateCredentials to validate a local Machine account

Sometime, I get exceptions which are not caused by wrong password:

"Multiple connections to a server or shared resource"

"The network path was not found"

 Question:

How can I get the real error code?   I need to tell if password failed or command failed. I cannot use text match, as Multl language support is required. 

I have tried various Exception Classes  but nothing gives correct code? 

thanks, Adrian

WIQL response object

$
0
0

Hello,

I am trying to read response of WIQL in C# but I don't know which object type I should use to fetch the result of WIQL query I fired on Azure DevOps server.

Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models.WorkItemQueryResult

WorkItemTrackingHttpClient witClient = connection.GetClient<WorkItemTrackingHttpClient>(); 
            

Wiql wiql = newWiql();  

 wiql.Query = "SELECT * "  

            + " FROM workitemLinks WHERE [System.Links.LinkType] = 'Parent' ";

WorkItemQueryResult tasks = await witClient.QueryByWiqlAsync(wiql); 

Console.WriteLine(tasks);

Response: Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models.WorkItemQueryResult

which obj i should use?

Windows Service for writing to shared folders

$
0
0
I create shared folder under first account and write to this folder from another one. I develop windows service but it has no access to write in shared folder. Service can write only when shared folder account login/password and Log On settings of service are identical. How can I tune service to write in shared folder with different account?
Viewing all 8156 articles
Browse latest View live


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