Cryptsharp C# Visual Studio 2022 no definition - c#

I've tried to run
string cryptedPassword = Crypter.MD5.Crypt(Passwort, new CrypterOptions()
{
{CrypterOption.Variant, MD5CrypterVariant.Apache}
});
from the cryptsharp documentation
But I don't seem to be able to run it.
Passwort is a random 5 char string
I have this code:
using System; using CryptSharp;
using System.IO;
using System.Security.Cryptography;
but keep running into errors:
Crypter has no definition for MD5
MD5CrypterVariant not available
What am I missing ?
Thanks in advance

If you want to use MD5 crypt algorithms, we need to install the following NuGet packages.
https://www.nuget.org/packages/CryptSharpOfficial/
Here is my code:
If there are still errors, you can try to reinstall the NuGet packages.

Related

How can i use an SQLiteAsyncConnection for Android using Xamarin?

I am trying to implement SQLite in a Xamarin solution using Visual Studio. However, i can not find the proper way to implement an SQLiteAsyncConnection.
I am following along a tutorial, which just passes a string to the constructor of the SQLiteAsyncConnection, however this is (no longer?) accepted. I googled to find a newer solution and almost everywhere found the solution to add a platform to the constructor, however that results in an error for me.
I think i might not have added the correct NUGet packages to the project(s). I have added the sqlite-net-pcl package to both the shared project and the android project.
I have also updated all NUGet packages today, rebuilt the solution and even deleted the /bin and /obj folder and it still is not working.
using System.IO;
using SQLite.Net;
using SQLite.Net.Async;
using Xamarin.Forms;
using SQLiteTest.Droid;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
[assembly: Dependency(typeof(SQLiteDB))]
namespace SQLiteTest
{
public class SQLiteDB : ISQLiteDB
{
public SQLiteAsyncConnection GetAsyncConnection()
{
const string fileName = "test.db3";
var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
var path = Path.Combine(documentsPath, fileName);
var platform = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
var cwLock = new SQLiteConnectionWithLock(platform, new SQLiteConnectionString(path, true));
var connection = new SQLiteAsyncConnection(() => cwLock);
return connection;
}
}
}
The error i get is:
Error CS0234 The type or namespace name 'Platform' does not exist in the namespace 'SQLite.Net' (are you missing an assembly reference?) SQLiteTest.Android D:\Mobile Apps\Mosh\SQLiteTest\SQLiteTest\SQLiteTest.Android\SQLiteDB.cs
Well, I am pretty sure you have not added the SQLite.Net.Platform.XamarinAndroid.dll package to your native Android project which is causing this issue when you use this dependency service.
If you are using SQLite-net and or SQLite.Net-PCL look for the Xamarin.Android platform dll int he path below:
packages\SQLite.Net-PCL.3.1.1\lib\MonoAndroid\`SQLite.Net.Platform.XamarinAndroid.dll`

VSCode C# Issue Adding An Assembly Reference

I have the C# VSC extension as well as the NuGet Package Manager installed. Here is my VSC version info:
First, I create a brand new console application in VSC with the command:
dotnet new console
This gives me the code:
using System;
namespace ReferenceTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
I now want to create a using System.Windows.Forms; reference. When I start typing this using statement however, intelli-sense fails me:
I found this question/answer already but in step #5 the autofill option shown is not there:
When I try to improvise and follow other instructions I've found in my searching by using the
NuGet Package Manager: Add Package
option, I cannot select System.Windows.Forms
I have looked for a project.json file per the instructions of several sites but I can only find a project.assets.json file and it doesn't look very similar to what I see in the examples I find. This issue is not only for System.Windows.Forms but other references I try as well.
Windows Forms and WPF applications are not supported in .NET Core, only in .NET Framework.
have a look at the following article:
https://stackify.com/net-core-vs-net-framework/

MS C# tutorial code doesn't work in VS2013?

I'm following through Microsoft's C# tutorial to eventually learn .net, I've put this code into my VS 2013 and for some reason the output shows that "$" was an unexpected character. Throughout the tutorial it hasn't mentioned using anything side from System,
From MS
using System;
class Program
{
static void Main()
{
var name = "Steve"; // use your name here
Console.WriteLine($"Hello {name}!");
}
}
What I have
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
var name = "John";
Console.WriteLine($"Hello {name}!");
}
}
}
VS2013 says it was expecting a ')' in the part of the line where its written ($"Hello {name}!");
If I remove the $ it outputs the sentence as it's written Hello {name}!
What could the issue be?
Interpolated Strings (string literals starting with $") were introduced in C# 6.0 (Visual Studio 2015).
Note that you can download and use the free Community Edition of Visual Studio 2015, if you are student, an open-source developer or and individual developer. Visual Studio 2017 is Launching on March 7 2017 and also has a free Community Edition and supports C#7.0 (introducing tuples with the new tuple syntax, pattern matching and much more).
Official Visual Studio Downloads site.
This is how you do it the old way (pre c# 6.0).
Console.WriteLine(String.Format("Hello {0}", name));

'ElasticTranscoder' does not exist in the namespace 'Amazon' (are you missing an assembly reference?)

I am stuck in a problem in which I am using Amazon SDK for .NET 4.5 on VS 2012
What my problem is that my code does not resolve ElasticTranscoder namespace
-I installed SDK 3 times all old to latest versions
-Checked on VS 2010 and 0n VS 2012
-Tried adding ref like 100 times again n again
Cleaing and rebuilding solutions
It never changes.
I am stuck for two days now.
Help me in finding the correct way to resolve this class AmazonElasticTranscoderClient
Anyone?
public void CreateJob(string Path, string bucket)
{
string accsessKey = CloudSettings.AccessKeyID;
string secretKey = CloudSettings.SecreteKey;
var etsClient = new **AmazonElasticTranscoderClient**(accsessKey,secretKey, RegionEndpoint.USEast1);
}
Hate to ask the obvious, but do you have these using statements at the top of your file:
using Amazon.ElasticTranscoder;
using Amazon.ElasticTranscoder.Model;
Also, try to create a brandnew project and pick the template:
Templates->Visual C#->AWS->App Services->Amazon Elastic Transcoder Sample
See if that installs and runs correctly - it does for me on VS2012 with .net 4.5

Microsoft.Office.Interop.Word reference not found

Recently, I have been escalated to work in a legacy project. This application is a plugin to Enterprise Architect that extracts the content to a .doc file. The point is, I tried to reference dll from different places, without success.
The error:
The type or namespace name 'Word' does not exist in the namespace 'Microsoft.Office.Interop' (are you missing an assembly reference?)
The places I have tried reference:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Office14\Microsoft.Office.Interop.Word.dll
C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Excel\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll
I am using Vistual Studio 2010 and I have Office 2013 installed in my machine, but also tested in a machine with Office 2010.
Appreciate any help.
Update:
Everywhere in the code the word 'Word' is underlined and the compilation error is above.
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
namespace EATec.Helpers
{
/// <summary>
/// Classe que manipula documento Word via Interop
/// </summary>
public class MSWordHelper
{
private static object format = Microsoft.Office.Interop.Word.WdOpenFormat.wdOpenFormatAuto;
private static object wrap = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue;
public static Microsoft.Office.Interop.Word.Document OpenDoc(object fileName)
{...
}
Legacy apps built against older versions of office may be doing something like (C++):
#import <msword9.olb> rename("ExitWindows","ExitWindowsWRD") rename "FindText","FindTextWRD") rename("ReplaceText","ReplaceTextWRD") rename("RGB","RGBWRD")
When I set up a new machine, I have a bat file to re-register the old files:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regtlibv12 "C:\Source\Office 97 dlls\mso9.dll"
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regtlibv12 "C:\Source\Office 97 dlls\msword9.OLB"
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regtlibv12 "C:\Source\Office 97 dlls\vbe6ext.OLB"
This has to be done when it's a newer version of Office installed on the PC.
Please note that regtlibv12 might not be on a windows 8 PC, and will need copying over from your old PC.
(Know this is nearly a year old, but just setting up a new PC at the moment...)

Categories