|
I'd start with related "clubs" in Freiburg. This is pretty abstract for remote work. i.e. high risk of failure.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
kiri008 wrote: in Freiburg
Presumably a city.
Presumably you want to interact with people directly.
So you will want to look to schools. Universities and high schools (whatever they are called there with student ages from about 14 to 18 years old.)
People interested in both music and computers.
You should take into account that enthusiasm is NOT the same as drive, dedication, willingness to work and deliver. So go into knowing that many contacts that seem like they want to do it will soon disappear and/or will never actually produce anything.
If you skip the need to for the personal interaction then you can create your own online open source project and then try to drum up interest (contributors) by publishing on other sites. However to be fair I would be very surprised if there were not already quite a few other projects out there doing the same thing - perhaps you should find one and contribute to it instead.
Also be careful about starting off too big. Start with the smallest project that does something and then add to it once that is completed.
|
|
|
|
|
Hi, everyone.
I´ve developped a C# program and I have a problem with configuration file.
I use Visual Studio 2022 and Windows 10.
To start, the program acesses the configuration file to read some information, then, after the user enters username and password the program grants (or not) use and opens main screen.
In config file there are information about server name and DB name. Everything worked fine until some days ago. I made some changes in config file (I removed a variable) and, in my computer it works, but in another computer it does't anymore.An exception appears about connection to DB which is closed. After many prints I foud out that the program is using variables not from the config file, and I don1t know where it comes from. I have also another program which deals with this config file. This file also can't access config file correctly.
Here is a snippet of the code of this second file:
ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = Base.caminho + Base.nomeArquivo + ".exe.config";
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
string Banco = config.AppSettings.Settings["Tipo"].Value;
string Servidor = config.AppSettings.Settings["Servidor"].Value;
string Empresa = config.AppSettings.Settings["Empresa"].Value;
string Local = config.AppSettings.Settings["Local"].Value;
string Diretorio = config.AppSettings.Settings["Pasta"].Value;
MessageBox.Show("Arquivo de configuração = " + fileMap.ExeConfigFilename + "\nServidor = " + Servidor + " Empresa = " + Empresa + " Local = " + Local +
"\nDiretório = " + Diretorio + " Banco = " + Banco);
if (!VerificaBasedeDados(Banco))
{
MessageBox.Show("Base de dados " + Banco + " inexistente!");
return;
}
In the first MessageBox.Show, the variable Banco (which is the DB name) is different from what is in the config file!
The 'if' after tests if the DB exists, but the program crashes before it.
The curious thing here is that in my computer it runs OK. In other computers it doesn't (I tried in 2). And before that change it ran OK too!
I tried to include back the variable but it didn't work.
Does anyone have any ideas?
Thanks.
|
|
|
|
|
Since you're calling OpenMappedExeConfiguration , I'm guessing that your code is writing to the config file at some point.
(If it's not, then why not simply use ConfigurationManager.AppSettings ?)
I'm also guessing that your users have installed your application in the "Program Files" directory; that your application doesn't run elevated; that your application is 32-bit; and that your application doesn't contain a manifest with a "requested execution level" attribute.
In which case, the users won't have permission to write to the config file, and you'll be hitting UAC virtualization:
How User Account Control works (Windows) | Microsoft Learn[^]
There will be a copy of the config file at a particular location within the user's profile, and that's what your application will be reading.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi, Richard.
Your assumptios are correct. Notice that users had access to the program and everything was fine. The configuration program (which is used to change parameters in config file) also worked without problem in my computer and in the other computers. After I made some changes (I remove one parameter) both programs stopped working in the other computers, but continue to work fine in mine. Maybe, as you say, some permissions were changed, but I have no idea of what was it. What do you suggest me to see in that article?
Thank you.
|
|
|
|
|
Quote: Windows 10 and Windows 11 include file and registry virtualization technology for apps that are not UAC-compliant and that require an administrator's access token to run correctly. When an administrative app that is not UAC-compliant attempts to write to a protected folder, such as Program Files, UAC gives the app its own virtualized view of the resource it is attempting to change. The virtualized copy is maintained in the user's profile. This strategy creates a separate copy of the virtualized file for each user that runs the non-compliant app.
Check under the %LOCALAPPDATA%\VirtualStore folder to see if there's a folder for your application with a copy of the config file in it.
I'd also recommend updating your application to include a manifest with the "request execution level" setting so that UAC virtualization doesn't apply to your application. You'll then need to handle the exception you get if you try to write to the config file and the user doesn't have permission.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Config files don't "stop working"; something must be wrong with the code.
And config files do not belong in the Program Files directory, we don't back that up. That directory should be read only for mortal men.
We back up the user directory where config files supposed to go.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hallo Gemeinde
wie kann ich nuget Paket in Visual Studio installieren,und es in meinem Projekt einbinden?
wäre schön wen ihr mir helfen könntet
MFG Kevin
|
|
|
|
|
|
Learning programming.
Step 1: Learn English.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I have a program I am working on. First I will explain what I have done and then get to the question. I have created a undo and redo functions that when undo, it deletes one character at a time from the string and puts it in a 'List<char>'. Then when you click redo, it goes to the 'List' and adds each character back to the string and deletes it from the list, one character at a time. You can see in the pictures the undo and redo menu button click events for them in the 1st pic. They get their functions from the 2nd pic., the undo redo class. I also have a keydown and text change function shown in pic. 3. All functions work good but the clearing of the 'list' that remains if they don't 'redo' all commands. I can undo and redo and have no problems, but I want it to delete the list contents after the user starts to type again after undoing and redoing. I have tried to put it in the text change but it keeps firing every time the list is over '0' and after the menu redo is enabled. I have tried putting in the buttons function, and I even tried to do the stack<char> process, but I could not get my head wrapped around that option. I know that 'richTxtDirections.Text = richTxtDirections.Text.Remove(richTxtDirections.Text.Length - 1);' deletes 1 character, but how do you say if the 'text.length +1' from where you stop to undo and redo, how to add a character. I hope I am explaining this fine for you to understand and that someone can possibly help me with this part, even if it is not adding 1 to the text.length. Thank you.
private void menuUndoEdit_Click(object sender, EventArgs e)
{
menuUndoEditClicked = true;
UndoRedo.undo();
if (richTxtDirections.Text.Length > 0)
{
richTxtDirections.Text = richTxtDirections.Text.Remove(richTxtDirections.Text.Length - 1);
richTxtDirections.Select(richTxtDirections.Text.Length, 0);
}
if (menuRedoEdit.Enabled == false)
{
menuRedoEdit.Enabled = true;
menuRedoEdit.Font = new Font(menuRedoEdit.Font, FontStyle.Regular);
menuRedoEdit.ForeColor = Color.Black;
menuRedoEdit.Text = "Redo";
}
menuUndoEditClicked = false;
}
private void menuRedoEdit_Click(object sender, EventArgs e)
{
menuRedoEditClicked = true;
UndoRedo.redo();
if (UndoRedo.charList.Count == 0)
{
menuRedoEdit.Enabled = false;
menuRedoEdit.Font = new Font(menuRedoEdit.Font, FontStyle.Italic);
menuRedoEdit.ForeColor = Color.DarkGray;
menuRedoEdit.Text = "Can't Redo";
}
menuRedoEditClicked = false;
richTxtDirections.Focus();
}
private void richTxtDirections_KeyDown(object sender, KeyEventArgs e)
{
lblCount2.Text = richTxtDirections.Text.Length + "/750";
if (richTxtDirections.Focused == true && richTxtDirections.Text != string.Empty)
{
if (menuUndoEdit.Enabled == false)
{
menuUndoEdit.Enabled = true;
menuUndoEdit.Font = new Font(menuUndoEdit.Font, FontStyle.Regular);
menuUndoEdit.ForeColor = Color.Black;
}
if (e.KeyCode == Keys.Z && (e.Control))
{
e.Handled = true;
menuUndoEdit.PerformClick();
}
else if (e.KeyCode == Keys.Y && e.Control)
{
e.Handled = true;
menuRedoEdit.PerformClick();
}
}
}
private void richTxtDirections_TextChanged(object sender, EventArgs e)
{
if (UndoRedo.charList.Count > 0 && menuRedoEditClicked == false)
{
UndoRedo.clearList();
}
}
public void undo()
{
if (frmDashboard.instance.tbrdDirections.Text.Length > 0)
{
charList.Add(frmDashboard.instance.tbrdDirections.Text[frmDashboard.instance.tbrdDirections.Text.Length - 1]);
}
}
public void redo()
{
if (charList.Count > 0)
{
var lastItem = charList.Last();
frmDashboard.instance.tbrdDirections.AppendText(lastItem.ToString());
charList.RemoveAt(charList.Count - 1);
}
}
public void clearList()
{
if (charList.Count > 0)
{
charList.Clear();
frmDashboard.instance.mnuRedoEdit.Enabled = false;
}
}
|
|
|
|
|
If you want to clear the list when someone "types", why do you have extra conditions in the text changed event?
if (UndoRedo.charList.Count > 0 && menuRedoEditClicked == false)
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Because I don't want it to clear it every time the text changes or keydown event fires but just after the user starts to type and quit. So I tried to put an extra condition to help stop it but its not. I hope I am explaining myself right.
|
|
|
|
|
I think you need to better explain what "type and quit" means. And you're talking as if "text changes" and "key down" are somehow independent. Maybe you should be looking at individual key presses in the preview key down event.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
I'm sorry Gerry. I wondered if I explained it wrong. Let me try this again. I was looking for help on how to delete the list<char> after the user is finished 'undo' commands or 'redo' commands, and the user starts typing on the keyboard, in the rich textbox, the rest of the directions for a recipe. I have used the the 'keydown' function to add the command that if a key was pressed, to delete the list if its greater than 0, but it deletes the list every time the user clicks the 'ctrl' and 'z' shortcut. I don't want it to empty the new characters added to the list by the 'undo' function, because there would be nothing left if he needs to 'redo' one or two. I was thinking if there was a text change, something like typing then stop to 'undo' and start typing again, that it may work, but it does not. Still deletes each character. I'm not even sure if that would be considered text change also. So now I am at a point I am asking if someone knows what how. I'm am fairly new at programming and have learned everything about it myself and doing it all myself. I know I explain things wrong or have the wrong terms for whatever, and I'm sorry if I did not explain better. My hubby always tells me I cant explain things the way they should be.
|
|
|
|
|
Your "key down" goes off and does something in "PerformClick()". I'd look there.
menuUndoEdit.PerformClick();
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
mjcs100 wrote: I have created a undo and redo functions that when undo, it deletes one character at a time from the string and puts it in a 'List<char>' Yah, that changes a char, but doesn't do/undo the last action.
You want a memento-pattern. It's easier, cleaner, and better, because it also can do/undo any font-changes.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I am not sure what controls you are using, but have you checked undo/redo is not already supported by the control - I would expect it is.
For example:
Windows Forms Redo[^]
WPF Redo[^]
Your implementation is very limited. As already mentioned you do not handle formatting - but you also assume the last character is the last one entered.
|
|
|
|
|
You might consider using Stack<t> versus List<t> for charList.
It has Push() (add to list), Peek() (look at the "topmost" list member), and Pop() (retrieve value and remove the topmost list member).
It is just the sort of LIFO collection it sounds like you may want.
|
|
|
|
|
I have this class User:
[Serializable()]
[XmlRoot("Users")]
public class Users
{
[XmlArrayItem(typeof(User))]
public List<User> UsersList { get; set; }
}
[Serializable()]
public class User
{
[System.Xml.Serialization.XmlAttribute("ID")]
public string ID { get; set; }
[System.Xml.Serialization.XmlElementAttribute("Name")]
public string Name { get; set; }
[System.Xml.Serialization.XmlElementAttribute("Username")]
public string Username { get; set; }
[System.Xml.Serialization.XmlElementAttribute("Password")]
public string Password { get; set; }
[System.Xml.Serialization.XmlElementAttribute("Email")]
public string Email { get; set; } = string.Empty;
}
And this:
private void Serialization()
{
var path = @"D:\Projects\repo\xml\users.xml";
var newUsers = new Users();
newUsers.UsersList = new List<User>();
var user = new User
();
user.Email = txtEmail.Text;
user.Name = txtName.Text;
user.Password = txtPass.Text;
user.ID =txtID.Text;
newUsers.UsersList.Add(user);
XmlSerializer serializer = new XmlSerializer(typeof(Users));
using (TextWriter writer = new StreamWriter(path,true))
{
serializer.Serialize(writer, newUsers);
}
}
And it saves this xml:
<?xml version="1.0" encoding="utf-8"?>
<Users xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<UsersList>
<User ID="A">
<Name>a</Name>
<Password>a</Password>
<Email>a</Email>
</User>
</UsersList>
</Users><?xml version="1.0" encoding="utf-8"?>
<Users xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<UsersList>
<User ID="SSSS">
<Name>s</Name>
<Password>s</Password>
<Email>ss</Email>
</User>
</UsersList>
</Users>
But I want to save the xml file in this format:
<?xml version="1.0" encoding="utf-8"?>
<Users xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<UsersList>
<User ID="A">
<Name>a</Name>
<Password>a</Password>
<Email>a</Email>
</User>
<User ID="SSSS">
<Name>s</Name>
<Password>s</Password>
<Email>ss</Email>
</User>
</UsersList>
The most important thing is that I have a windows form with some textboxes and every time I run the application and register a new user I want it to pe added in <UsersList> not overwritten over the existing ones
|
|
|
|
|
You need to deserialize the existing file contents, and overwrite the entire file. If you just serialize the new users and append it to the file, you'll end up with multiple XML documents in a single file, which is not valid.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Take a look at your Serialization method. Why are you creating a new list of Users, adding one user to it, and then overwriting the file you already have?
Method should do one thing and only one thing. Your Serialization method is not responsible for creating a list of users and adding users to it. It should be renamed SerializeUsersToFile and do only that job.
Maintaining a list of users should be done by your Users class. It should expose methods for adding and removing them.
Another class can be created that handles Serializing and Deserializing a Users class to the file. When you want to update the file, you call the SerializeUsersToFile method and pass the Users object to it. When you want the users to be loaded from the file, you call another method, DeserializeUsersFromFile, and it should return a populated Users object.
|
|
|
|
|
To add to what the others have said, I'd suggest that you read this: That's not a database, dude![^] XML is a transfer format, not a data storage format.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Please help make this code work. I'm trying to run it in Visual Studio 2022. Thanks.
<pre lang="C#">
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Numpy;
using Python.Runtime;
using Keras;
using Keras.Layers;
using Keras.Models;
using Keras.Optimizers;
using Keras.losses;
namespace SQLInjectionDetection
{
class Program
{
static void Main(string[] args)
{
var trainData = File.ReadAllLines("tokens.csv")
.Select(l => l.Split(','))
.Select(s => new { Token = s[0], Label = int.Parse(s[1]) })
.ToList();
var random = new Random();
trainData = trainData.OrderBy(d => random.Next()).ToList();
var splitIndex = (int)(trainData.Count * 0.8);
var trainDataSubset = trainData.Take(splitIndex).ToList();
var testDataSubset = trainData.Skip(splitIndex).ToList();
var vocabulary = new HashSet<char>(trainDataSubset.SelectMany(d => d.Token).Distinct());
var tokenToIndex = vocabulary.Select((c, i) => new { Token = c, Index = i }).ToDictionary(t => t.Token, t => t.Index);
var maxSequenceLength = trainDataSubset.Max(d => d.Token.Length);
var trainTokenized = Tokenize(trainDataSubset, tokenToIndex, maxSequenceLength);
var testTokenized = Tokenize(testDataSubset, tokenToIndex, maxSequenceLength);
using (Py.GIL())
{
dynamic keras = Py.Import("keras");
dynamic np = Py.Import("numpy");
var input = new Input(shape: 1000);
var embedding = new Embedding(vocabulary.Count, 32).Apply(input);
var lstm = new LSTM(32).Apply(embedding);
var output = new Dense(1, activation: keras.activations.sigmoid).Apply(lstm);
var model = new Model(inputs: input, outputs: output);
model.Compile(optimizer: new Adam(), loss: new BinaryCrossentropy(), metrics: new[] { "accuracy" });
var trainX = trainTokenized.Item1;
var trainY = trainTokenized.Item2;
var testX = testTokenized.Item1;
var testY = testTokenized.Item2;
model.Fit(trainX, trainY, batchSize: 32, epochs: 10, validationData: (testX, testY));
Console.Write("Enter user input: ");
var userInput = Console.ReadLine();
var inputTokenized = TokenizeInput(userInput, tokenToIndex, maxSequenceLength);
var prediction = model.Predict(inputTokenized).GetData<float>()[0, 0];
Console.WriteLine($"Prediction: {(prediction > 0.5 ? "Malicious" : "Safe")} (Score: {prediction:F4})");
var testMetrics = model.Evaluate(testX, testY);
Console.WriteLine($"Test loss: {testMetrics[0]:F4}");
Console.WriteLine($"Test accuracy: {testMetrics[1]:F4}");
}
}
private static (NDarray, NDarray) Tokenize(List<dynamic> data, Dictionary<char, int> tokenToIndex, int maxSequenceLength)
{
var numExamples = data.Count;
var X = np.zeros((numExamples, maxSequenceLength));
var Y = np.zeros((numExamples, 1));
for (var i = 0; i < numExamples; i++)
{
var tokens = data[i].Token;
var label = data[i].Label;
Y[i] = label;
for (var j = 0; j < tokens.Length; j++)
{
var token = tokens[j];
var index = tokenToIndex[token];
X[i, j] = index;
}
}
return (X, Y);
}
}
}
|
|
|
|
|
We have no idea what it is fully supposed to do, or what it does that you didn't expect / doesn't do that you did. And we have no access to your data so we couldn't test it if we wanted to.
So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how to use it then a quick Google for "Visual Studio debugger" should give you the info you need.
Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.
Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|