Recent Discussions
MSB4184: The expression "[System.IO.Path]::GetDirectoryName('')" cannot be evaluate
Hi got this error now after I updated my VS IDE .... The path is not of a legal form. WinFormsSQLExamplePro C:\Program Files\dotnet\sdk\10.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Windows.targets <_WinRTRuntimeDllDirectory>$([System.IO.Path]::GetDirectoryName('%(_WinRTRuntimeDllReferencePath.FullPath)'))</_WinRTRuntimeDllDirectory> <_CsWinRTOrTargetingPackLibDirectory>$([System.IO.Path]::GetDirectoryName('$(_WinRTRuntimeDllDirectory)'))</_CsWinRTOrTargetingPackLibDirectory> Note the top most path entry contains a '%' character , whereas the 2nd path contains a '$' character... Not sure what is going on ... (happened after VS update)241Views0likes1CommentIt appears and error that does not exist
I am using VS 2022 Community and when i develope asp.net apps it happens sometimes that it appears an error that does not exist adn only after many hours of searching for the error or rewriting the same code the app begins to run correctly. Somehitng simmilar happened to any of you ? how can i avoid these strange behaviour of the compiler ? Thank you in advance Luis Martin109Views0likes1CommentConnect .Net (4.6.2) to Dataverse using the Dataverse plugin
Hi Microsoft Tech Community, We have a Dataverse environment in our tenant, and I have its URL. I'm building a .NET application and need to connect it to Dataverse for data access. From the Learn docs, ChatGPT, and Copilot, it seems I need to use an App ID (Client ID) and Client Secret in the connection string (e.g., via Microsoft.PowerPlatform.Dataverse.Client). However, the Dataverse environment itself doesn't expose any App ID or Client Secret—where would I even find those if they exist? Here's the code snippet we found online that's using OAuth with AppId and RedirectUri, but we're unsure about the app registration part: using Microsoft.Crm.Sdk.Messages; using Microsoft.PowerPlatform.Dataverse.Client; using Microsoft.Xrm.Sdk; class Program { // TODO Enter your Dataverse environment's URL and logon info. static string url = "https://yourorg.crm.dynamics.com"; static string userName = "email address removed for privacy reasons"; static string password = "yourPassword"; // This service connection string uses the info provided above. // The AppId and RedirectUri are provided for sample code testing. static string connectionString = $@" AuthType = OAuth; Url = {url}; UserName = {userName}; Password = {password}; AppId = 51f81489-12ee-4a9e-aaae-a2591f45987d; RedirectUri = app://58145B91-0C36-4500-8554-080854F2AC97; LoginPrompt=Auto; RequireNewInstance = True"; static void Main() { //ServiceClient implements IOrganizationService interface IOrganizationService service = new ServiceClient(connectionString); var response = (WhoAmIResponse)service.Execute(new WhoAmIRequest()); Console.WriteLine($"User ID is {response.UserId}."); // Pause the console so it does not close. Console.WriteLine("Press the <Enter> key to exit."); Console.ReadLine(); } } Do I need to create a separate app registration in Microsoft Entra ID (Azure AD), link it to the Dataverse environment (perhaps as an application user?), and then use that app's Client ID/Secret in my .NET code? If so, could someone outline the exact steps, including permissions and Power Platform admin center setup? Any guidance or links to official walkthroughs would be greatly appreciated—thanks!154Views0likes1CommentGrant/Revoke permissions to Windows local certificates (certlm) in non-admin mode
I am working on granting/revoking permissions to windows local certificates (certlm) using Visual C++ 2022. The challenge is that this needs to be performed in non-admin privileges. We would need to remove "Everyone" permissions and grant read permissions for our NT Service account to windows local certificates (certlm). Is it possible to perform under non-admin privilege? It would be great help if can get solution for this.91Views0likes1CommentSharePoint List View Threshold Error while Fetching 5000+ Records in list.
I am fetching data from a SharePoint list that contains more than 5000 records inside my function. While retrieving the data, I am getting the following error: “Flow Reminders→ The attempted operation is prohibited because it exceeds the list view threshold.” Scenario: The SharePoint list has 5000+ items. Data is being fetched programmatically. The error occurs during query execution. What I need help with What is the recommended and best-practice approach to retrieve large datasets from a SharePoint list without hitting the list view threshold? Questions: What is the recommended approach to fetch large data from a SharePoint list without hitting the list view threshold? Any suggestions, examples, or documentation references would be greatly appreciated. Thanks.85Views0likes1Comment.NET
Hi everyone! 👋 I’m new to this community and currently learning .NET App Development. I’m really excited to join and connect with developers here. I believe the discussions and knowledge shared in this community are very valuable, especially for beginners like me. I’m looking forward to learning from your experiences and improving my development skills. If you have any tips, recommended resources, or advice for someone starting with .NET, I would really appreciate it. Happy to be part of this community! 😊113Views3likes1CommentEntity Framework DB permissions
I want to use Entity Framework with a .Net 9 app but have had difficulty finding information on what DB permissions it needs in the app database. I've found a couple old StackOverflow posts but having created a user with the recommended db_datareader, db_datawriter and db_ddladmin and updated the app connection string to use it and now the app won't start. What more does it need?100Views0likes1CommentConfigure registry permissions
Hi I have strange problem to set specific permission to a registry key. According to Microsoft's https://learn.microsoft.com/en-us/dotnet/api/system.security.accesscontrol.registrysecurity?view=net-10.0, it should work like this: private static RegistryKey CreateRegistryKey(RegistryKey parentPath) { RegistryKey childKey = parentPath.CreateSubKey("myKey"); RegistryAccessRule rule = new RegistryAccessRule( new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null), RegistryRights.ReadKey | RegistryRights.Delete, InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow); RegistrySecurity childACL = childKey.GetAccessControl(); childACL.AddAccessRule(rule); ShowSecurity(childACL); childKey.SetAccessControl(childACL); return childKey; } But if the code is executed in a windows service, I missing my permission!? How can this be? Am I doing something wrong? Have I overlooked something?76Views0likes1CommentNeed help with ClickOnce deployment on .NET Framework 4.7.2 – "Unidentified program" warning
Hello, I have a WinForms application built on .NET Framework 4.7.2 that I'm publishing using ClickOnce from Visual Studio Community 2022 (official Microsoft version). Even after signing the application with a valid SHA256 V3 self-signed certificate, when I publish and try to install it via ClickOnce, I receive a warning saying the program is unidentified. Additionally, when I try to install the application on a machine that has antivirus software, the antivirus flags the program precisely because of the missing/certificate validation issue. How should I proceed? I'd like to know the correct way to publish with ClickOnce so that the application is fully recognized as valid by Windows, since I'm running into these antivirus validation problems. Thanks in advance for any guidance!64Views0likes1CommentHttp requests from client to server project with cookie auth
Start a new Blazor app with individual accounts. Add a controller to the server project. [ApiController] [Route("api/[controller]")] [Authorize] public class TestController : ControllerBase { private readonly ILogger _logger; public TestController(ILogger logger) { _logger = logger; } [HttpGet("public")] [ProducesResponseType(typeof(string), StatusCodes.Status200OK)] [AllowAnonymous] public IActionResult GetPublic() { return Ok(JsonConvert.SerializeObject("Now is the time for all good men to come to the aid of the public party.")); } [HttpGet("private")] [ProducesResponseType(typeof(string), StatusCodes.Status200OK)] public IActionResult GetPrivate() { return Ok(JsonConvert.SerializeObject($"Now is the time for all good men and {User.Identity.Name} to come to the aid of the private party.")); } And route it in in Program.cs ... builder.Services.AddControllers(); // + ... app.MapControllers(); // + Create a HttpClient for the API public class CookieHandler : DelegatingHandler { public CookieHandler() { InnerHandler = new HttpClientHandler() { AllowAutoRedirect = false }; } protected override Task SendAsync( HttpRequestMessage request, CancellationToken cancellationToken) { request.SetBrowserRequestCredentials(BrowserRequestCredentials.Include); request.Headers.Add("X-Requested-With", ["XMLHttpRequest"]); return base.SendAsync(request, cancellationToken); } } public class LocalHttpClient : HttpClient { public LocalHttpClient(CookieHandler h) : base(h) { } } in the <em>client</em> project and register it in <em>both</em> the client and the server project. builder.Services.AddTransient(); builder.Services.AddTransient(); Update the client side page Auth.razor to use it @page "/auth" @using Microsoft.AspNetCore.Authorization @attribute [Authorize] @* @rendermode InteractiveWebAssembly *@ @rendermode InteractiveAuto @inject LocalHttpClient _HttpClient @code{ protected override async Task OnInitializedAsync() { HttpResponseMessage rx = await _HttpClient.GetAsync("https://localhost:7131/api/Test/public"); Public = await rx.Content.ReadAsStringAsync(); rx = await _HttpClient.GetAsync("https://localhost:7131/api/Test/private"); Private = await rx.Content.ReadAsStringAsync(); if(!rx.IsSuccessStatusCode) { Private = (Private ?? "") + rx.StatusCode.ToString(); } await base.OnInitializedAsync(); } string Public { get; set; } string Private { get; set; } } <PageTitle>Auth</PageTitle> <h1>You are authenticated</h1> <p>Public: <code>@Public</code></p> <p>Private: <code>@Private</code></p> <AuthorizeView Context="AuthorizeViewContext"> Hello @AuthorizeViewContext.User.Identity?.Name! </AuthorizeView> The authorisation doesn't work.65Views0likes1CommentDebugging Java script in old asp core app
Hy, I need to modify an asp.net.core app witch I made years ago. in version 2.2. I do succeed to alter C# code in visual studio (2022), but I need to alter also some Java script. The problem is that if I try to do so and I want to debug it it seems that the script in my browser (MS Edge) is not changing. I have enabled Java script debugging in VS. I emptied the browsers cache but nothing seems to help. When I run the application in debugging mode and hit F12 I still see the old script. Please help!84Views0likes1CommentSimple request for Visual Studio's Find and Replace operation
Doing a Find + Replace operation in VS, I could wish there was an option, when selecting to do so over the whole project or solution, to choose which types of files to include or exclude. For example, in a classic Web Forms project, I'd like to omit the designer pages. I've been caught out by this ore than once ... :( (More fool I...)57Views2likes2CommentsGetting a ConnectionString empty error in a webapi project with .net 10
I'm running in .NET 10 with the most recent update for everything. I'm in EF. I'm ASP.NET Core. Below is my program.cs file. Inside of the program.cs file, when I call to get my connection string, I get back what I expect. When I hit the LoginController, I see the settings in the IConfiuguration that is handed in. However, when I set a breakpoint in the FSMUserStore constructor, I check the context that is handed in, and it's connection string is not set correctly (at all). I've run through Visual Studio debugger so many times, and tried so many things, I'm just lost on this. I think the problem is in how I am setting up for dependency injection in the program.cs file, but I've tried so many things that I don't know what else to try. Anyone have a suggestion? using ElmahCore.Mvc; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using Microsoft.IdentityModel.Tokens; using Portal.Libraries; using PortalDataModels.Models; using System.Text; using Twilio.TwiML.Voice; var builder = WebApplication.CreateBuilder(args); IConfiguration configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .AddEnvironmentVariables() .Build(); // connString get's the correct value var connString = configuration.GetConnectionString("DefaultConnection"); // Add services to the container. // For Entity Framework builder.Services.AddDbContext<PortalDataModels.Models.POA_CSMContext>(options => options.UseSqlServer(configuration.GetConnectionString(connString))); builder.Services.AddScoped<IUserStore<FSMUser>, FSMUserStore>(); builder.Services.AddIdentity<FSMUser, IdentityRole>() .AddEntityFrameworkStores<POA_CSMContext>() .AddUserManager<UserManager<FSMUser>>() .AddSignInManager<SignInManager<FSMUser>>() .AddDefaultTokenProviders(); builder.Services.AddElmah<ElmahCore.Sql.SqlErrorLog>(options => { options.ConnectionString = connString; options.SqlServerDatabaseTableName = "Elmah_Error"; //Defaults to ELMAH_Error if not set options.OnPermissionCheck = context => false; }); // Adding Authentication builder.Services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; }) // Adding Jwt Bearer .AddJwtBearer(options => { options.SaveToken = true; options.RequireHttpsMetadata = false; options.MapInboundClaims = false; options.TokenValidationParameters = new TokenValidationParameters() { ValidateIssuer = true, ValidateAudience = true, ValidAudience = configuration["Jwt:ValidAudience"], ValidIssuer = configuration["Jwt:ValidIssuer"], IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["Jwt:Key"])) }; }); builder.Services.AddScoped<UserManager<FSMUser>>(); builder.Services.AddControllers(); // Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi builder.Services.AddOpenApi(); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.MapOpenApi(); } app.UseHttpsRedirection(); app.UseAuthentication(); app.UseAuthorization(); app.MapControllers(); app.Run();119Views0likes1CommentPaytmgateway integration throwing exception error
While integration paytmgateway to my asp.net project, throwing exception "exception occurred while verifying checksum. Invalid padding can't be removed. What to do? I put every data right like merchant key ,MID etc . Plz guide me69Views0likes0Comments- 85KViews1like9Comments
Blazor parameter passed by reference
I got the impression that in Blazor parameters are always effectively passed by value which is why you need to use EventCallback for two-way binding to send a change in the parameter value back up to the component that passed it. But not so; reference types really are passed by reference. Therefore if a child component updates a parameter value that is a reference type then the value in the parent is changed and all you need to do is call `StateHasChanged` on the parent. Is this as intended? Have I misunderstood the documentation? Example: https://drive.google.com/file/d/1i1Rh36nHU1Z2voyHDtLVZ9GyziLw9AQq/view?usp=sharing (Don't seem to be able to attach here and it's not really feasible to inline a whole Blazor project.)268Views0likes2Comments