Click here to Skip to main content
15,894,460 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I added a reference to Presentation Core 4.0 in my project, then the method in which it is used to check if Win key is down (only in this method Presentation Core 4.0 is used in my project and solution), I removed all references to this method, which means the lines inside this method cannot run, and I forgot to remove the reference to Presentation Core in my project.

I removed the reference to Presentation Core 4.0 from the project. Do I have to publish it again to improve installed program size and/or performance or it's the same?

What I have tried:

I have this method that uses Presentation Core 4.0 but with no references to the mehtod.

static bool isWinPrsd()
{
    if (System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.LWin) ||
        System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.RWin))
    {
        return true;
    }
    else
    {
        return false;
    }
}
Posted
Updated 18-Jan-19 9:53am
v3

1 solution

If you have a reference to an external library, under References in Solution Explorer, the files ARE deployed with the project, even if there is no code actually using the library.

If you have code in the C# files in the project, that code is compiled and ends up in the resulting .EXE.

Unused code doesn't have any impact on performance, though it will have a small impact on the resulting .EXE or .DLL file size.
 
Share this answer
 
Comments
john1990_1 18-Jan-19 16:02pm    
Thx, I don't find the name "presentation" in the Windows File Explorer folder of my program (source code) (with PresentationCore 4.0 referenced), it's built in in Windows I think so it doesn't take up space in the published program nor Windows File Explorer soure code folder other than the sentence in which it says it's referenced, maybe VS detects that this dll is not used (there are lines using it but these lines cannot possibly run) and doesn't care to load it from Windows or even removes the sentence that links it to it from the published program.
Dave Kreskowiak 18-Jan-19 16:20pm    
WHAT??? Where did I ever mention "presentation" or Windows File Explorer?

I said under the References in SOLUTION EXPLORER. You know that window that starts with your Solution as the top line, then the Project under it, the Properties, and REFERENCES.
john1990_1 18-Jan-19 16:27pm    
I can see PresentationCore 4.0 in my references inside my VS when the solution is open, but my question is if I don't use one or more of the references at all that are added inside VS in references section, do they still take size when the program is published (inside the Windows File Explorer folder where it's published and can be installed into Apps & Features), what if the reference is built in in Windows (I didn't make it nor copy it from somewhere), does it still take size in my Windows File Explorer folder of the source code of the project? I think I'm clear.
Dave Kreskowiak 18-Jan-19 18:27pm    
I already said this. Yes, if an assembly is referenced, even if your code doesn't use it, it is still deployed.
john1990_1 18-Jan-19 18:47pm    
Thx a lot, will it increase published program size if the referenced DLL is built in in Windows?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900