Struggling to understand project referencing? [duplicate] - c#

This question already has answers here:
How to solve circular reference?
(6 answers)
vs2008 circular references (c#)
(6 answers)
Resolving Circular References (C#)
(6 answers)
Closed 4 years ago.
So I have many projects in my solution.
AppName
AppName.Game
AppName.Common
AppName.Core
I'm currently hosting networking in AppName.Common because AppName requires it to initialize it, and AppName.Game requires certain classes from it to store propertys based on them classes.
The problem comes when I can't reference AppName.Common and AppName.Game both ways. Common requires the Game's classes to know what to call when a new packet comes in, and the game project needs the networking (DotNetty) to use the classes for the propertys.
I can't see why Microsoft have blocked referencing both ways, it seems like such a struggle to get to where you want to be? Is there any workaround for this?

The simplest and best way to do what you need is to move the code that both projects need somewhere that they can both access without having a circular reference. Add another project to your solution:
AppName.Networking
Put all the network stuff that both projects need into that and reference it.

Related

C# - is it possible to modify values and call functions while the process is running? [duplicate]

This question already has answers here:
How can I write on another process memory?
(4 answers)
How to remote invoke another process method from C# application
(2 answers)
Closed 3 years ago.
I've been starting to do some decompiling of my C# programs and got some interesting results by editing the dlls, but is it possible to change values and call functions in a running process given that I know what the names of the variables or functions are?
Doesn't any cheat to any game do exactly that?
I mean, if I understand you correctly, there is software called
Cheat Engine which allows you to modify process variables values, inject dll's and much more.

Class library C# [duplicate]

This question already has answers here:
C# using others code
(4 answers)
Closed 5 years ago.
I made a blank solution in C#( without any project ) and I added two Class Library Projects named "PersonLibrary" and "AnotherLibrary". The problem is that when I try to access the PersonLibrary from AnotherLibrary with: "using PersonLibrary;" I get this error: The type or namespace name "PersonLibrary" could not be found.
1
If you go to AnotherLibrary -> References -> Add Reference, you should see an option to add projects in solutions and add PersonLibrary .
Once you add a reference, You can use whatever the available methods.

Control.ProductName in WPF [duplicate]

This question already has answers here:
Application.ProductName equivalent in WPF?
(7 answers)
Closed 8 years ago.
Is there something similar to the following property in WPF?
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.productname(v=vs.110).aspx
Thanks.
Not that I know of. But you can easily create this method yourself.
The actual code used by WinForms has several levels of fallback: it first look for an AssemblyProductAttribute on the assembly defining the control, then at the file version and finally falls back to the first part of the namespace.
You can copy that logic (or the parts that are relevant to you) directly from .net source code: http://referencesource.microsoft.com/#System.Windows.Forms/ndp/fx/src/winforms/Managed/System/WinForms/Control.cs#f7c944851a004a6e

Automatic way to put all classes in separate files [duplicate]

This question already has answers here:
How can I extract all classes into separate file?
(3 answers)
Closed 9 years ago.
I've started to refactor/clean up big project. Some of files contains few small classes or few enums (yeah, it is very messy;/ ).
Is there some method or tool to automatically divide files with few enums/classes and create separate files for each of them?
As Fredrik Mörk said - Resharper is very good tool and has possibility to do what I need. But of course as almost all good tools it costs (for one it is cheap, for another not:) ).
Maybe there is some free tool for such simple refactoring? (my boss will not pay for Resharper - he told me that I need 'hammer' not a whole workshop:) )
Resharper has a refactoring that moves a type to a separate file. Might be that it can be applied on a higher level (as project); don't have it installed on this machine to verify though.
Edit: noticed in the online help that there is a refactoring called Move Types Into Matching Files that does exactly what you are asking for.
CodeRush xpress (free) also supports Moving a type into a matching file

Singleton problem in c# [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicates:
What is the correct way to create a single instance application?
What is a good pattern for using a Global Mutex in C#?
Suppose i have created an exe i want that exe must run only once ..how it is possible please give suggestion
If I understand your problem correctly this has nothing to do with having a singleton implementation. You simply need to check if your executable is currently running.
You can do this by calling Process.GetProcesses() or Process.GetProcessesByName(NameOfExecutable) and checking the return values.
Alternatively use a Mutex as suggested above by others.

Categories