.NET Programming

134K

Solutions

39K

Contributors

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

Share tech news, updates, or what's on your mind.

Sign up to Post

I have a microsoft Azure Storage Account, with a blob container.

I am storing different types of files in this account.  I have excel files, some zipped up xml files, a .net app, and some sql scripts.

Currently I have AD access to this storage account.

What I need to do is configure the best way for my IT team to access these files if necessary and be able to read the excel files and potentially download the other files if needed.

This will be a rare event but the game plan needs to be in place.

I am seeing things regarding API, and URL's but no idea at this point how to configure.  

Please help.   At this point I am not sure if I need more AD rights from my infrastructure team to configure this.

This will be a long time storage facility to archive some retention items in the company.

But should our Audit team need to see anything , IT will be called upon to retrieve.  

I want to setup something that will not require an Azure expert to view these files.

I also want to keep this inexpensive as some of these retentions are literally lifetime.
0
hi guys

The environment I'm working in has around 150+ servers. Our team have to apply patches and keep these servers updated on a regular basis which they haven't done as yet. Now, the issue we have is that these servers are not just owned by the infrastructure and security teams, as that would be easy to manage. But the business analysts, business intelligence and applications teams own a good percentage of these too.

I need to put strategies in place so that my team, infrastructure&security, ensures that when these updates are applied that the impact is minimised and that we don't suddenly have updates which affect the applications sitting on those servers and firefighting errors.

One of my ideas was to ensure that there is a testing environment. But if I did, would I then liaise with the development teams to replicate everything that is on the production environment onto their testing too and regularly? So that when they make changes to development, they do the same onto testing?

What is the approach you have found works best?

Thanks for helping
Yash
0
Access to XMLHttpRequest at 'http://someURL' from origin 'http://someURL' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed.


This is a call to a REST API controller action method. I enabled CORS on the top of controller like below:
[EnableCors(origins: "*", headers: "*", methods: "*")]
 public class TestController : ApiController
    {
    }

Open in new window


Also in the web.config:

<httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Credentials" value="true" />
        <add name="Access-Control-Allow-Headers" value="Content-Type" />
        <add name="Access-Control-Allow-Methods" value="GET,POST,PUT,DELETE" />
		<add name="Access-Control-Allow-Origin" value="*" />
      </customHeaders>
    </httpProtocol>

Open in new window


Any ideas please thanks.
1
I have a vb.net program that was done several years ago and has references to .NET 2.0. How can I change this to .NET 4?
.NET 2.0
0
Hi

We are facing some issues with performance, we cannot seem to process data fast enough.

Firstly what I would need to know is what we are trying is technically possible

I'm trying to process hundreds of thousands of records
each record takes approx 500ms to process due to things like hitting external API's

I'm only able to process 85-100 records per second

The server is in a datacenter, its am 8 cpu skylake cpu, however when the app runs it uses approx 140 threads, and cpu sits around 6%

The app is multithreaded and i've tried threads, threadpool, Async/await, parallel foreach/invoke etc, most of the 500ms is waiting for API's to respond.

My question is related to processing throughput with the given parameters
i.e. if it takes 500ms to process 1 record, (and its running consistently on 140 threads), does 100 records per second so like a near limit?

I know this question is tough to answer but I need to know is i should be focusing on code performance tuning or look at other solutions
0
The "Introduction to classes" tutorial in following link assumes .NET Core SDK and Visual Studio Core are installed.

https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/intro-to-csharp/index

Is Visual Studio IDE sufficient tool for coding, compiling, and running this tutorial?  File -  New  - Project  -  Visual C#  -   Console App (.NET Framework)
0
I have Microsoft Visual Studio Professional 2017 installed in my computer.

I need to know if ".Net Core SDK" is installed?  From Visual Studio main menu, Help -  About Microsoft Visual Studio, there are Installed Products.
I don't see ".Net Core SDK" in the list.  Does this mean it's not installed ?
0
Hello,

I am interested in knowing the career path for WPF.  Is PRISM OR SILVERLIGHT essential for it.
Thanks
0
Hello,

I have been tasked with working on a legacy application.  This application is written in VB.NET WinForms, and there is quite a lot of code in the project already to handle things like database connectivity, error handling, reporting, logging, user notifications, etc.

The last developer to work on the app added a second project to the solution for a custom WPF control he created.  It's still titled "WpfControLibrary1", and the control is "UserControl1" so i'm guessing he didn't spend much time on it.  The control itself uses MVVM C# and it's been added into a winform in the original project with no code behind it.

My question is this: How can I access this pre-existing classes, modules, and forms in the original project from the new control?

For example, if I want to export data to Excel in the old project I would simply instantiate the "DataExport" class and pass the dataset to its "ToExcel" method.   Similarly, how could I access a property/method from the main form?

I'm really not very familiar with WPF, and could use a nudge in the right direction.  Perhaps i'm not searching for the right terms, or maybe it's just not possible.  However, I'm really not looking to re-invent the wheel here, just need to figure out how to leverage/access the pre-existing code for what would normally be 5 minutes worth of work if it weren't for the WPF.

Thanks in advance for your time.
0
Hi

I want to learn how to use REST to interact with wep application API in VB.net.
Where do I start?

Thanks
0
I have a winform loading a combo box...and am not getting desired output in the combo box.  

the values repeat themselves with this :  AttachmentsLibrary.Attachments

Here is my class that loads the connection and creates the list to populate the datasource of the combo box.
namespace AttachmentsLibrary
{
    public class SqliteDataAccess
    {
        public static List<Attachments> LoadFormId()
        {
            using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
            {
                var output = cnn.Query<Attachments>("select Distinct Form from Attachments Order by Form Asc", new DynamicParameters());
                return output.ToList();
            }
        }      

       

        private static string LoadConnectionString(string id = "Default")
        {
            return ConfigurationManager.ConnectionStrings[id].ConnectionString;
        }
    }


}

Open in new window



Here is the code behind on my winform:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using InfoPathAttachmentEncoding;
using AttachmentsLibrary;

namespace SP2007AttachmentArchival
{
    public partial class frmDownLoadAttachments : Form
    {
        private StringBuilder sb = new StringBuilder();
        List<Attachments> attachment = new List<Attachments>();

        public 

Open in new window

0
I am getting the following error when trying to run my winform.

Here is the error:

System.Configuration.ConfigurationErrorsException
  HResult=0x80131902
  Message=Configuration system failed to initialize
  Source=System.Configuration
  StackTrace:
   at System.Configuration.ConfigurationManager.PrepareConfigSystem()
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
   at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
   at System.Diagnostics.DiagnosticsConfiguration.Initialize()
   at System.Diagnostics.DiagnosticsConfiguration.get_IndentSize()
   at System.Diagnostics.TraceInternal.InitializeSettings()
   at System.Diagnostics.TraceInternal.get_Listeners()

Inner Exception 1:
ConfigurationErrorsException: Only one <configSections> element allowed per config file and if present must be the first child of the root <configuration> element. (C:\Repo\SP2007AttachmentArchival\SP2007AttachmentArchival\bin\Debug\SP2007AttachmentArchival.exe.Config line 6)

Open in new window



Here is my app.config file in code:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="default" connectionString="Data Source=.\Sharepoint2007Archive.db; Version=3;" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <configSections>
    
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
    </providers>
  </entityFramework>
  
</configuration>

Open in new window

0
I am building a .net class for SQLite.
I am using Dapper instead of Entity Framework.

How would I build a query that takes a variable in the where statement.
I am seeing different ways to do this..so trying to do this with best practices.

Here is my code without the where clause:

namespace AttachmentsLibrary
{
    public class SqliteDataAccess
    {
        public static List<Attachments> LoadFormId()
        {
            using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
            {
                var output = cnn.Query<Attachments>("select Id, Form from Attachments", new DynamicParameters());
                return output.ToList();
            }
        }      

       

        private static string LoadConnectionString(string id = "Default")
        {
            return ConfigurationManager.ConnectionStrings[id].ConnectionString;
        }
    }


}

Open in new window



The SQL will be like this

select * from table where Form = 'value from a combobox on my winform' and where RequestId = ' value from a search box'
0
We recently replaced a set of user defined functions with CLR assembly functions. The query in question does call one of these functions but the definition is ridiculously simple. Here is the old SQL Server scalar UDF definition:
CREATE FUNCTION [fn].[APAD]
(
	@Value VARCHAR(8000)
	, @tablename varchar(8000) = null
	, @columnname varchar(8000) = null
)

RETURNS VARCHAR(8000)
WITH SCHEMABINDING
AS

BEGIN
	RETURN ltrim(rtrim(@Value))
END

Open in new window


The replacement CLR function is defined as follows in C#:
	[SqlFunction(IsDeterministic = true)]
	public static string APAD(string value, string tableName, string columnName)
	{
		return value?.Trim();
	}

Open in new window

and the SQL Server function entry point is defined as:
CREATE FUNCTION [fn].[APAD]
(
	@Value NVARCHAR(4000),
	@TableName NVARCHAR(4000),
	@ColumnName NVARCHAR(4000)
) RETURNS NVARCHAR(4000)
AS
EXTERNAL NAME ASI.fn.APAD
GO

Open in new window


I don't see how this could be causing the problem but I'm exploring every possible angle at this point. Has anyone heard of CLR assembly functions causing deadlocks?
0
I am creating a .net winform utlizing the latest .net framework.

The winform is a c# .net framework winform.

I am building a class library to serve as my Model to the SQLite database.

Should I be using the .net framework class library or is it a good idea to get in the habit of always using the .net standard.

I am not clear on when I should truly be worried about .net standard.

I am not writing the winform in .net core.

Thanks,
0
Hi EE,

How do redirect/configure the Powershell ISE or VSCode editors to run PowerShell scripts using PowerShell console (Powershell v6) terminal?

I have already tried the info in these posts:

https://techcommunity.microsoft.com/t5/ITOps-Talk-Blog/Configure-Visual-Studio-Code-to-run-PowerShell-for-Windows-and/ba-p/283258
https://4sysops.com/archives/vscode-as-a-console-for-powershell-core-6-part-1-multiple-shells/

And this works in VScode if I run the script from the command line.

But when I try to run the PS script with the intention of debugging it I get the following screen: see attached.

Basically what I need is when I hit the start debugging button F5 I need the terminal version to default to 'pwsh' (powershell v6)instead of PowerShell integrate

Below is my settings json file:

{
    "terminal.integrated.shell.windows": "c:/Program Files/PowerShell/6/pwsh.exe"
}


"shellLauncher.shells.windows": [
    {
        "shell": "C:\\Windows\\system32\\cmd.exe",
        "label": "cmd"
    },
    {
        "shell": "C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe",
        "label": "PowerShell 5.1"
    },
    {
        "shell": "C:\\Program Files\\PowerShell\\6\\pwsh.exe",
        "label": "PowerShell 6.0"       
    },
    {
        "shell": "C:\\Program Files\\Git\\bin\\bash.exe",
        "label": "Git bash"
    },

],

Open in new window

Any assistance is welcome.

Let me know if my query needs clarification.

Thank you.
Capture.PNG
1
If you had an old Asp.net web forms c# application using sql server for back end that needed to be re-written to use modern technologies , what would you use?

But you must use sql server 2016.

Would you use asp.net web forms?
Asp.net mvc 5?
Asp.net core?
Angular front end?

Also what technology would you use to connect to sql server?
Web API? Entity Framework dB first? Entity Framework code first? Any other way?
0
Hi All,

Well it looks like some of the simplest things are causing me the most trouble.

I am trying to download an image, VB.NET,  that has some 'Embedded' code/script in the URL.

Example:
https://img.discogs.com/Zs_NkppmE3Jh1t9qpaETecKVLJU=/fit-in/150x150/filters:strip_icc():format(jpeg):mode_rgb():quality(40)/discogs-images/R-5514089-1395334223-8017.jpeg.jpg

This URL will produce an Image when run in a browser, but will return a 503 Server Unavailable error when run from within my code. I have tried 3 different approaches and each one produced the same 503 error...  The following are the three things that I have tried. Any help is (again)  greatly appreciated..

...
My.Computer.Network.DownloadFile(ThisImage, LocalImageFileName)
...

Open in new window


...
myWebClient.DownloadFile(ThisImage, LocalImageFileName)
...

Open in new window


Public Function MyDownloadImage(url As String, saveFilename As String)

        Dim httpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
        Dim httpWebResponse = DirectCast(httpWebRequest.GetResponse(), HttpWebResponse)
        If (httpWebResponse.StatusCode <> HttpStatusCode.OK AndAlso httpWebResponse.StatusCode <> HttpStatusCode.Moved AndAlso httpWebResponse.StatusCode <> HttpStatusCode.Redirect) OrElse Not httpWebResponse.ContentType.StartsWith("image", StringComparison.OrdinalIgnoreCase) Then
            Return 0
        End If
        Using stream = httpWebResponse.GetResponseStream()
            Using 

Open in new window

0
I'm working on a Windows Forms project and it calls Web Services. This is how the project is setup (my new job)

1. The Windows Forms solution
2. Web Services solution
3. Windows Forms solution has references to the Web Services . Screenshot below (not the best naming convention, I know)
e1.png
4. I downloaded Fiddler to see if I can see what Web Services method is being called. I see some logging but not Web Services.

Anyway I can see  which web services method is being called?
0
Since I want to build tool similar to this link: https://github.com/Genymobile/scrcpy

I have followed https://github.com/quamotion/madb SharpAdbClient is a .NET library that allows .NET applications to communicate with Android devices. It provides a .NET implementation of the adb protocol, giving more flexibility to the developer than launching an adb.exe process and parsing the console output.

I don't know it is possible or not to stream android screen to PC by using this library or not? Or any suggestion. Thank in advance!
0
Does double data type overflow in C# language?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            double max = double.MaxValue;
            double min = double.MinValue;
            Console.WriteLine($"The range of double is {min} to {max}");

            double what = max + 3000;
            Console.WriteLine(what);

            // Go to http://aka.ms/dotnet-get-started-console to continue learning how to build a console app! 
        }
    }
}

Open in new window


output is attached.   Why there is no overflow?
0
I am analyzing  what is the best portable solution for a database....and it seems the question is between SQL LITE and MS SQL CE 4.0 sp1.

With that said I have a very large table in SQL Server.  So far it has created some 500 files of SQL for CE and it looks like LITE will be even more as the file sizes are smaller.

With that said It looks like Microsoft has pretty much abandoned CE compared to LITE.  

I will need to use this in a Winform c# app that will connect to one table...perform a very basic LINQ query.

so my question is 2 parts.  Which is the best.

And finally since this is creating so many files in my migration ...what is the best way to execute these files versus clicking on them and running them one at a time.

I would imagine they could be ran in batch with powershell or someothe tool.

Any guidance would be great!


Thanks,
0
I have an MS Access database and need to interface with a C# DLL that is about to be created for me (as a COM object).  My C# guy has no experience in interfacing with MS Access, and I have only interfaced Access with COM objects that I have purchased (EASendMail etc).  

We have run a few tests, and I can half interface with his test DLL (once referenced), but the Intelisense isn't working correctly.  However, whilst I am sure that we can overcome that one easily enough, it's the return messages that I am struggling to get my head around.  How do I tell Access to listen for them and then, trigger an event/function?

I know this is a little vague - but I could really do with some pointers to get started.
0
CRM 2011 upgrade

We are trying to upgrade a CRM 2011 system however the IT group will not allow us to use production data in dev to test the upgrade.  Does anyone have experience working with very confidental data that cant be shown to most users?  

I have worked on some projects where we wrote an encrypt/decrypt program to make the data anonymous during the upgrade and then it was decrypted afterwards when in the new system.

Any suggestions would be helpful.
0
Hi

I have an ASP.net website that I built in Visual Studio 2017. Can I control which .net framework it is published in?
My hosting company only supports up to 4.5

Thanks
0

.NET Programming

134K

Solutions

39K

Contributors

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.