โŒ

Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

Same function comes to JIT multiple times in .NET PROFILER

I have developed my own .NET profiler (C++) using CORPROFILER API. And am doing the instrumentation that calls C# helper assembly file.

I have set the following event mask

ProfilerInfo->SetEventMask( COR_PRF_DISABLE_TRANSPARENCY_CHECKS_UNDER_FULL_TRUST | COR_PRF_MONITOR_EXCEPTIONS | COR_PRF_USE_PROFILE_IMAGES | COR_PRF_MONITOR_JIT_COMPILATION | COR_PRF_MONITOR_MODULE_LOADS);

My question is, Some functions comes to JITcompilationstarted callback repeatedly. Then my profiler getting down because of this issue. How to avoid same function comes to JIT multiple times?

Wed May 15 12:58:07 2024 - [INFO1] System.Void Builder:EnsureCapacity(System.Int32) 2540 PID: 6020 Wed May 15 12:58:07 2024 - [INFO1] System.Void DisposableData:Release() 2540 PID: 6020 Wed May 15 12:58:07 2024 - [INFO1] System.Void Builder:EnsureCapacity(System.Int32) 6656 PID: 6020 Wed May 15 12:58:07 2024 - [INFO1] System.Void DisposableData:Release() 6656 PID: 6020 Wed May 15 12:58:07 2024 - [INFO1] System.Void Builder:EnsureCapacity(System.Int32) 2540 PID: 6020 Wed May 15 12:58:07 2024 - [INFO1] System.Void DisposableData:Release() 2540 PID: 6020 Wed May 15 12:58:07 2024 - [INFO1] System.Void Builder:EnsureCapacity(System.Int32) 6656 PID: 6020 Wed May 15 12:58:07 2024 - [INFO1] System.Void DisposableData:Release() 6656 PID: 6020 Wed May 15 12:58:07 2024 - [INFO1] System.Void Builder:EnsureCapacity(System.Int32) 2540 PID: 6020 Wed May 15 12:58:07 2024 - [INFO1] System.Void DisposableData:Release() 2540 PID: 6020 Wed May 15 12:58:07 2024 - [INFO1] System.Void Builder:EnsureCapacity(System.Int32) 6656 PID: 6020 Wed May 15 12:58:07 2024 - [INFO1] System.Void DisposableData:Release() 6656 PID: 6020 Wed May 15 12:58:07 2024 - [INFO1] System.Void Builder:EnsureCapacity(System.Int32) 2540 PID: 6020 Wed May 15 12:58:07 2024 - [INFO1] System.Void DisposableData:Release() 2540 PID: 6020 PID: 6020

How to avoid the same function from instrumentation?

error: Automation error. The system cannot find the file specified in vb6

I have an application in VB6 and need to create an object of a class that is part of another .dll (written in VB.NET). Now I am using the CreateObject() method (I am following the same logic used in other parts of the application) but it is giving me this error:

Automation error. The system cannot find the file specified.

Since VB6 is quite old I have not worked a lot with it and don't understand why my .dll is not working but works for others. Am I missing any step?

Public Function DoRun() As Object
    Set DoRun = CreateObject("U_DoRun.ClassName",SERVERNAME)
End Function

I have tried to use this command:

C:\Windows\Microsoft.NET\Framework\v4.0.\regasm.exe c:\windows\syswow64\U_DoRun.dll /codebase /tlb:c:\windows\syswow64\U_DoRun.tlb

After I do this if I try to give a value to a variable of the class it gives another error:

Could not load file or assembly 'NetArch, Version=2.0.0.0, Culture=neutral, PublicKeyToken=3544813d6c2e85c4' or one of its dependencies. The specified file could not be found.

and also the object of the class seems to be empty (It says 'No variables') which makes me think that it does not create the object correctly. What can I do to solve this?

Google Analytics Reporting API V4 for .NET having issue

When I run and try to run application I got below error on GoogleCredential.FromStream(stream); line:

"Error creating credential from JSON. Unrecognized credential type"

Below is my client_secret details:

{
  "installed": {
  "client_id": ".......",
  "project_id": ".......",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_secret": ".......",
  "redirect_uris": [ "urn:ietf:wg:oauth:2.0:oob", "http://localhost" ]
  }
}

C# Code

// Create the DateRange object. Here we want data from last week.
            var dateRange = new DateRange
            {
                StartDate = DateTime.UtcNow.AddDays(-7).ToString("yyyy-MM-dd"),
                EndDate = DateTime.UtcNow.ToString("yyyy-MM-dd")
            };
            // Create the Metrics and dimensions object.
            var metrics = new List<Metric> { new Metric { Expression = "ga:sessions", Alias = "Sessions" } };
            var dimensions = new List<Dimension> { new Dimension { Name = "ga:pageTitle" } };

            //Get required View Id from configuration
            var ViewId = ConfigurationManager.AppSettings["ViewId"];

            // Create the Request object.
            var reportRequest = new ReportRequest
            {
                DateRanges = new List<DateRange> { dateRange },
                Metrics = metrics,
                Dimensions = dimensions,
                ViewId = ViewId
            };
            var getReportsRequest = new GetReportsRequest();
            getReportsRequest.ReportRequests = new List<ReportRequest> { reportRequest };
       

and

public static GetReportsResponse GetReport(GetReportsRequest getReportsRequest)
        {
            var analyticsService = GetAnalyticsReportingServiceInstance(ConfigurationManager.AppSettings["KeyFileName"]);
            return analyticsService.Reports.BatchGet(getReportsRequest).Execute();
        }
        private static AnalyticsReportingService GetAnalyticsReportingServiceInstance(string keyFileName)
        {
            string[] scopes = { AnalyticsReportingService.Scope.AnalyticsReadonly }; //Read-only access to Google Analytics
            GoogleCredential credential;
            //string Fpath = File.Exists(keyFileName)//System.IO.Path.GetFullPath("/" + keyFileName);
            string Path = @"C:\Users\umang.soni\source\repos\Google Analytics API Console\Google Analytics API Console\" + keyFileName;
            using (var stream = new FileStream(Path, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                //I Got error on below line.
                credential = GoogleCredential.FromStream(stream);
                    credential.CreateScoped(scopes);
            }
            // Create the  Analytics service.
            return new AnalyticsReportingService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "Google Analytics API Console",
            });
        }

I Googled a lot but not get any meaning full answer.

My application is console application.

Google Analytics API and .Net

Google announced the Analytics Data Export API some days ago, thereby making it much easier to get analytics data for a site. The API debuted with Java and JavaScript clients, but no direct .Net support (other than going straight for the XML). It seems the API is similar to the other Google Data APIs though, and there's a .Net client for those. Has anyone tried using the components in that library to get at the analytics data?

I'm in the process of building an ASP.Net MVC site and thought I'd use Google Analytics to generate "Most viewed" lists and stuff like that (since Google is probably better at weeding out spurious requests, robots, etc.). If you have any thoughts on that idea, I'd much appreciate hearing them too.

call instance method that has dependency injections without calling DI Constructor

I have an ASP.NET Core Web API that I made using the repository pattern. When a request comes to my controller, I call one of my services dependency methods, then in that service that was just called, I call another service, which is just my repository layer.

This class in the repository layer MyRepo.cs relies on a DBClient.cs class I created.

Appsettings.json:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "Database": {
    "ConnectionString": connection string"
  }
}

Program.cs:

// APPSETTINGS CONFIG
builder.services.Configure<DatabaseConfig>(
    config.GetSection(DatabaseConfig.ConfigSectionName)); //Appsetting `Database` property


builder.services.AddScoped<IMyService, MyService>();
builder.services.AddScoped<IMyRepo, MyRepo>();

MyService.cs:

public class MyService: IMyService
{
    private IMyRepo _myRepo;

    public SurveyFormDataServices(IMyRepo myRepo) 
    {
        _myRepo= myRepo;
    }

    public IEnumerable<MyTypes> GetTypes()
    {
        var types= _myRepo.GetTypes();
        ...
    }
}

MyRepo.cs:

public class MyRepo: IMyRepo
{
    private SqlConnection sqlConnection;

    public IEnumerable<MyType> GetTypes()
    {
        using (sqlConnection = DBContext.GetConnection())
        {   
            // ...
        }
    }
}

DBClient.cs:

public sealed class DBClient
{
     private readonly DatabaseConfig _options;
     private static string connectionString = string.Empty;

     public DBClient(IOptions<DatabaseConfig> options)
     {
         _options = options.Value;
         connectionString = _options.ConnectionString;
     }

     public static SqlConnection GetConnection()
     {
         SqlConnection connection = new SqlConnection(connectionString);
         connection.Open();
         return connection;
     }
}

As you can see in my DBClient.cs class, the constructor has a parameter IOptions from the injected AppSettings. I did the options pattern by also binding it to a class that represent the settings.

What my issue is, in the MyRepo.cs, if I do this:

using (sqlConnection = DBClient.GetConnection())

The connectionString property in my DBClient.cs file will be empty, since I am guessing I did not instantiate with new DBClient(IOptions). I want to avoid this and even if I do it like this, I get an error because I don't know how to pass in IOptions, and I rather not.

How can I call or use the DBClient.GetConnection() function and ensure GetConnection() will have the connectionString value from the appsettings.json?

I am using VB.net, connected to an Access database, and want to retrieve the column names and data items in the columns

I am trying retrieve some column names and items in that column, from an ACCDB 2016. (By actual names and not index numbers). I have the connection working because I can retrieve a list of my USER table, and the system tables.. Here is the the table info -

Ideal would be to pick a table column and then retrieve the data in it. I already know about looping through 1 to many concepts. My issue is that I can't seem to find the column name property first, then loop to grab the data items.. Thank you so much for any help!

I tried various help/searches on the internets, of course.

Can I Embed an Existing ASP.NET Application Inside My New Flutter App to Access Its Services?

Is it possible to open an existing and functional application within my new application and access all of its services? Note that my application is developed in Flutter, while the other application is developed in ASP.NET?

I attempted to integrate an existing ASP.NET application into my new Flutter app to access its services. I expected the ASP.NET app to open seamlessly within my Flutter app, allowing me to utilize its functionalities. However, I encountered compatibility issues between the two frameworks, preventing successful integration.

Need help in managing large data streaming over websockets(SignalR)

I have an application which has large dataset that is streamed through websockets(SignalR) currently and visible in a ag-grid table and there are various realtime updates that keep on flowing to browser through socket related to that data.

Since the data is huge and updates are also becoming very large, I want to control the data in table through pagination and send updates for only the specific data that is in the view... Updates are currently asynchronous that my backend receives through third party system and backend sends all updates to UI. So I wanted to get the suggestions how can I implement this change to my system and make it more robust.

Number of entries expected in End Of Central Directory does not correspond to number of entries in Central Directory

We have code to upload a zip file, at the start of the process if the zip file contains __MACOSX folder in the zip it will strip these folders/files from the zip and pass the file bytes on.

The issue we're having is that further down the chain if we create a new ZipArchive using fileBytes we get the error:

Number of entries expected in End Of Central Directory does not correspond to number of entries in Central Directory.

This only happens when the zip doesn't contain any __MAXOSX folders to be removed. Commenting out the below code prevents this error ever occuring.

// Strip MacOSX folder if zip
var fileBytes = uploadController.FileBytes;
if (uploadController.FileName.EndsWith(".zip", StringComparison.CurrentCultureIgnoreCase))
{
    try
    {
        using (var data = new MemoryStream(fileBytes))
        {
            var changed = false;
            using (var archive = new ZipArchive(data, ZipArchiveMode.Update))
            {
                while (true)
                {
                    var osx = archive.Entries.FirstOrDefault(
                        c => c.FullName.StartsWith("__MACOSX/", StringComparison.CurrentCultureIgnoreCase)
                    );
                    if (osx == null) break;
                    osx.Delete();
                    changed = true;
                }
            }

            // Archive is updated once disposed
            if (changed)
            {
                fileBytes = data.ToArray();
            }
        }                    
    }
    catch (Exception e)
    {
        return new ObjectReturnMethodResult<UploadedFileV2>("Uploaded zip appears to be invalid." + e.Message);
    }
}

When running the above code on a zip that doesn't contain __MACOSX why might it create this error?

'}' expected when trying redirect my buttons in the sidebar to a different Form

I am getting an '}' expected error on the buttonNamesAndFormNames method. I can seem to be figuring out why it's throwing the error as you can clearly see it at the end of the method. I have included the other methods as I am trying to get my dynamically created buttons to redirect to my DocumentUnderstand form. I want these buttons in my SideBar to redirect to all different forms in VB.NET. I have tried 'Clean' & 'Rebuild', but the error is still there. Any help is greatly appreciated.

    ' Define an array with button names and their corresponding form names
Private buttonNamesAndFormNames() As (buttonName As String, formName As String) = {
    ("Document understanding", "DocUnderstand.vb"),
    ("Button 2", "Form2"),
    ("Button 3", "Form3"),
    ("Button 4", "Form4"),
    ("Button 5", "Form5"),
    ("Button 6", "Form6")
    ' Add more button names and corresponding form names as needed
}

Private Sub SideMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    InitializeDynamicControls()
End Sub

Private Sub InitializeDynamicControls()
    ' Add buttons dynamically based on the buttonNamesAndFormNames array
    For Each pair In buttonNamesAndFormNames
        Dim button As New Button()
        button.Text = pair.buttonName
        button.Dock = DockStyle.Top
        AddHandler button.Click, AddressOf OpenForm
        Panel1.Controls.Add(button)
    Next
End Sub

Private Sub OpenForm(sender As Object, e As EventArgs)
    ' Handle button click event
    Dim button As Button = DirectCast(sender, Button)
    Dim index As Integer = -1

    ' Find the index of the clicked button in the buttonNamesAndFormNames array
    For i As Integer = 0 To buttonNamesAndFormNames.Length - 1
        If buttonNamesAndFormNames(i).buttonName = button.Text Then
            index = i
            Exit For
        End If
    Next

    ' Open the corresponding form based on the index
    If index >= 0 AndAlso index < buttonNamesAndFormNames.Length Then
        Dim formName As String = buttonNamesAndFormNames(index).formName

        ' Assuming that the form files are in the same namespace as SideBar
        If Not String.IsNullOrEmpty(formName) Then
            Dim formInstance As Form = CType(Activator.CreateInstance(Type.GetType(formName)), Form)
            formInstance.Show()
        Else
            MessageBox.Show("Invalid form name or form not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    Else
        MessageBox.Show("Invalid button index.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End If
End Sub
โŒ
โŒ