|
Either way. If they are related function, then the same assembly makes sense. If not, then separate them by functional groups.
A DLL file (a class library in Visual Studio) is a .NET file which is compiled and is identical to an EXE file, except it lacks an entry point (the "Main" function).
By putting black box code in a separate assembly, you release the compiled file and the inner workings can't be seen or changed by the users. Much the same as you don't normally look at or try to modify the mechanics of the string.Substring method in your code (though you can access the Reference Sources if you want a look at how .NET does it).
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thanks for the info OriginalGriff.
I might have a closer look at how dll files are created in C#.
Brian
|
|
|
|
|
A "black box" is a "component" (class) with a "clean" explicit interface.
There are specific "properties and methods" (class members) that are explicitly made public for the sole purpose of interfacing with the component.
Contrast this with a component where EVERY member is simply defaulted to public so that there is no control over how the "internals" of the component are accessed.
It's a design strategy.
"Black Boxes" can be / have static members, much like the "Math" class.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hi Gerry.
One of the reasons to have black boxes is to keep the code cleaner rather than have pages of code I can refer to the black boxes in my code which reduces the amount of code written.
It's a bit like not having to write a lot of code when you want text printed to the screen in C# you just need to type Console.WriteLine ("").
If I was to write a text adventure program in c# then one of the black boxes would handle the players inventory.
As I'm new to C# what type of things should I be looking for that point me in the wright direction and would help me create black boxes.I have books on C# and some reference on the internet.
Brian
|
|
|
|
|
You're talking about "modules" in general and confusing it with the "black box" (concept) which has to do with "interfacing" and "hiding" module "internals".
On the surface they all look the same; it's the design (or lack thereof) of the interface that differentiates them.
Contrast this with a "white room" where designers come up with new products, (supposedly) "isolated" from the risk of "stealing" from other people's products.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I call them black boxes as that's the best way to describe them.
To me a black bode is some code that's not in the main program but can be called then needed.
Having black boxes reduces the amount of code that is written as the rest of the code is in black boxes.
I cam across a example program recently where the main program calls another program to do a check and display the status. The program it called to me would be a black box as the code for the called program does not appear in the main program.
example:
//Main Program
dante.checkTemperature
dante.showAttributes
I'm wondering if there is a limit to the number of black boxes I can have in a program and how I would refer to a certain black box as the code above is for one black box.
Brian
|
|
|
|
|
So I've been working with making my windows form app work on multiple monitors such as centering my progress dialog on the screen that the app is running on using the Screen Device Name, running some math and setting the parameters to center the dialog window. So this works fine when the app starts on the monitor, but when I move the app to another monitor, the Screen device name remains the same.
I'm trying to figure how to update the Screen device name when you move the app to another monitor.
Searching the web so far has produced nothing because I don't even know what to call this.
But I will start with the Screen class after this and see what I can dig up.
So far I've been able to save the App's window parameters so that it opens again on the right monitor, if the app is closed in a minimum state I can make it normal and open on the correct monitor.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Maybe my issue is a flawed thought in how I calculate this. I used the device name because I wasn't able to do the math on the primary monitor.
public ProgressDialog()
{
InitializeComponent();
this.AutoScaleMode = AutoScaleMode.Dpi;
this.AutoSize = true;
Screen myMonitor = Screen.FromControl(MainForm);
this.StartPosition = FormStartPosition.Manual;
this.Top = (myMonitor.WorkingArea.Height / (double)2) - (this.Height / (double)2);
if ((myMonitor.DeviceName.Contains("DISPLAY1")))
this.Left = myMonitor.WorkingArea.Width / (double)2 - (this.Width / (double)2);
else
this.Left = myMonitor.WorkingArea.Right - (myMonitor.WorkingArea.Width / (double)2) - (this.Width / (double)2);
Console.Write("Stop");
}
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I just writing this in case I need to go back and figure it out again. So far it works pretty good but I'm sure there's a better way of doing this. Well the idea is that if you have multiple displays, 2 or 3 running horizontal, and you keep moving the app around to a different monitor, or overlapping 2 monitors, and you want to get your progress dialog centered in the application. I tried a whole of ways of doing this, but the parameters I saved on the main form when changed, would not update when accessing it from the progress dialog.
So I took my global class and added a Rectangle to it. I wrote this in VB but used this forum to ask the question.
Friend Module Global360
Public Property GOnline As Boolean
Public Property MfRectangle As Rectangle
End Module
Then on the MainForm in the Event Location Changed, I added this
If mainForm.WindowState = FormWindowState.Minimized
Global360.MfRectangle = Rectangle.Empty
Else
Global360.MfRectangle = Nothing
Global360.MfRectangle = new Rectangle(mainForm.Left, mainForm.Top, Me.Width, Me.Height)
Application.DoEvents()
End If
And in the Progress Dialog, I wrote this in Form New
If (Global360.MfRectangle <> Rectangle.Empty) Then
Me.StartPosition = FormStartPosition.Manual
Me.Top = ((Global360.MfRectangle.Height - Me.Height) / 2) + Global360.MfRectangle.Y
Me.Left = ((Global360.MfRectangle.Width - Me.Width) / 2) + Global360.MfRectangle.X
Else
Me.StartPosition = FormStartPosition.CenterScreen
End If
I'll change the code as soon as I get it working in C#
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
If you get this working "too well", you'll find that if you don't keep ALL your monitors on, the app will wind up "displaying" on a monitor that you don't have access to (if that's where it last displayed).
It shows in the Task Bar but that doesn't help in moving it (again).
(Same thing happens with UWP because it does all the "location saving and restoring" for you).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I didn't think of that!
So far so good, works great across 3 monitors horizontal.
And works on my notebook with one monitor.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I'm new to programming in C#.
Could someone tell me what is wrong with this code please.
Every time the user clicks the button a count of user clicks is shown in a text bo.
namespace Click_Counter
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
int Clicker=0;
}
public void button1_Click(object sender, EventArgs e)
{
Click_Counter();
}
}
public Click_Counter()
{
Clicker++;
ClickCounterBox.Text = "You clicked the button " + Checker.ToString();
}
}
|
|
|
|
|
Clicker is declared inside the Form constructor:
public Form1()
{
InitializeComponent();
int Clicker=0;
} Which means it is a local variable - it's scope is restricted to the set of curly brackets in which it is declared. When it goes out of scope (i.e. outside those curly brackets) it no longer exists, and the variable is destroyed (but not it's content - you'll find out about the difference later).
So you can't use it in your Click_Counter method even if it was in the same class - which it isn't - or would compile, which it wouldn't as it doesn't specify a return type. Only Constructors can be defined without a return type! And "Clicker" is not the same as "Checker"!
Move the Clicker definition to class level, so it's not inside any method, move the Click_Counter method inside the Form1 class, give it a return type, and get the names right:
namespace Click_Counter
{
public partial class Form1 : Form
{
private int Clicker=0;
public Form1()
{
InitializeComponent();
}
public void button1_Click(object sender, EventArgs e)
{
ClickCounter();
}
public void ClickCounter()
{
Clicker++;
ClickCounterBox.Text = "You clicked the button " + Clicker.ToString();
}
}
} I declared Clicker as private so it's only available inside the class - you only expose what you need to to the outside world!
I've also changed the name from Click_Counter to ClickCounter, as that's the standard naming convention: you don't use underscore in names except in special cases in C#
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thanks OriginalGriff for the information.
I altered my C# code to make the corrections you made but it's C# is indicating errors in ClickCounter() next to the word public [method must have a return type] and also an error in ClickCounterBox [The name ClickCounterBox does not exist in the current ccontext].
What must I do to correct this?
Brian
|
|
|
|
|
1) Read my code again, and compare it to yours!
2) Check your Design view and see what you named the textbox you are trying to display in.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi OrginalGriff.
I'm still getting an error on the "ClickCounter()" code [next to the word public]
I've made the changes and this is my updated code.
namespace Click_Counter
{
public partial class Form1 : Form
{
private int Clicker = 0;
public Form1()
{
InitializeComponent();
}
public void button1_Click(object sender, EventArgs e)
{
ClickCounter();
}
public ClickCounter()
{
Clicker++;
ClickCountBox.Text = "You clicked the button " + Clicker.ToString();
}
}
}
Brian
|
|
|
|
|
Member 14154627 wrote: public ClickCounter() You must declare a return type in all methods other than constructors and destructors as OriginalGriff already showed you. It should be:
public void ClickCounter()
|
|
|
|
|
|
Thanks for the suggested book.
I managed to download a copy of it and it looks useful.
Brian
|
|
|
|
|
I think I have solved the problem by adding the word "void"
public void ClickCounter()
I remembered that you need to add the word void if it does not return a value.
All seems to work OK now thanks.
Brian
|
|
|
|
|
Well done!
You should be able to work most of those problems out just by looking at the error messages that VS gives you and a little thinking. But we all make these mistakes from time to time...
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
what is best alternative to microsoft bot framework?
I mean bot developed by microsoft bot framework must be deployed on azure, which is paid.
What are the free alternatives,
I mean I want to develop bot in dotnet and host it on my own server/hosting environment.
cheers
--nitin
=====================================================
The grass is always greener on the other side of the fence
|
|
|
|
|
You will most likely find the answer by using a search engine: Google or Bing being "the best" (whatever that means).
|
|
|
|
|
AFAIK, there is no free alternative; it would be rather expensive to maintain a network like that and open it up for free.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hello Team,
Good Morning!! We are using C# Code that was converted from Java which we have used in Script Task in SSIS in order to compare 2 report files and based on missing units we are trying to generate those and place in one folder.
We have 4 Variables that we have created in SSIS package and calling them in Script task.
It gives an error as below :
- [ Dts Script Task has encountered an exception in user code ]
- [ Cannot load script for execution ]
Need some help in this regards.
|
|
|
|