I have a solution with 8 related projects (which are all C# Windows Desktop Applications--- a utilities suite). All 8 projects use a pair of class files which are in each project as linked files.
I can set breakpoints in the linked code, and step thru it, but I cannot edit. When I try, I get the error "Changes are not allowed if the project wasn't built when debugging started." I've made sure to perform a clean and build before running, but that doesn't help.
Is it not possible to edit linked class files?
Related
How would a programmer migrate an old C# project to reasonably modern Microsoft VS 2019?
It seems I must explore moving files to sub directories to get more modern features in the IDE, in particular [Git] compatibility.
The source code compiles and executes. The original source code is from [many] years ago.
Preliminary Solution ... At least for git
I am not claiming this is useful. I have only used git for one check in and one diff so far.
A new project was created for Windows Forms (WF).. Since WF was the style of the old project. Then the whole older project was copied to the newly created project/solution folder. That seemed to be a requirement again for git as provided by MS VS2019. Git directories for both projects were deleted since there was [no] history. Uninformed Delete. Version control was disconnected and reconnected with warnings by IDE. Old project added to new solution via context menu. Eventually after some undesired behavior a check in and diff was performed. A single diff (compare to unmodified). Compare to unmodified is not being offered . Commit is possible. I have my doubts and suspicions. More testing required.
Should I create a new similar project and try to put the old files in the new project? The tags indicate CSharp. Any smarter approaches?
Is it easy or difficult to move the location of source files within the project?
C# project display shows files such as
FormXX and FormXX.Designer.cs and FormXX.resx
style. I assume I must preserve those relationships.
So I would like to keep the original source as much as possible. Yet there is a Git incompatability problem asked in another question.
The source files are at the same level as the solution files. Messages from the IDE lead me to believe that this may not be the modern style.
Simply put, I want to make a C# front-end for an R project.
Ellaborating a bit: I want to use a function I define in an R project (RTVS) in my C# code using RDotNet, but extensive search in Google yielded no results (by the way, it seems that even the question is not asked, so I understand that I may be having a "you did not see the obvious" problem here... but, if so, I'm failing to see the obvious for hours!).
To be more specific:
I have an R project named RLab
In the same solution, I have a C# project named RFrontEnd
In RFrontEnd I have C# methods that use RDotNet to execute R code
In RLab I have an R file named Script.R with R code I want to use in RFrontEnd
I want to use something like rEngine.Evaluate("source('Script.R')"); in RFrontEnd to access the code I wrote in Script.R
A few points:
I cannot simply reference an R project in a C# project
I can run the project by pointing to the file in the R solution, as in rEngine.Evaluate("source('C:\<Project Address Here>\Script.R')");, but that makes my project dependent on the specific location of the R file in the file system. I know I can make this location a parameter I could place in a config file, but there must be a more elegant, built-in solution... right?
In the RInteractive window I can simply use source('Script.R') and my functions are loaded normally
Version specifications:
RDotNet version is 1.7.0
Microsoft R Open version is 3.4.4
R Tools for Visual Studio version is 1.3
Visual Studio version is Community 2017
Can anyone please help me with that?
Thanks and cheers!
It just came to me that you can link files to a project, so I can place links to my .R files in my C# project and have them copied to a folder in the project's output.
This is done by dragging the .R files from the R project with the Alt key pressed and dropping them somewhere in my C# project (preferentially in a properly named project folder) and then going to the newly linked .R file's properties and setting it to be copied to the project's output (this is absolutely essential, as a link is not a true file and will not be on the expected file system folder when the project is built, unless the file is marked to be copied on build).
This is not the elegant solution I have expected, but it does get my .R files to a known, fixed location, even if I have to deploy my project somewhere else, so I can do something like rEngine.Evaluate("source('R Scripts/Script.R')"); and get my functions properly set to run in the R environment (via RDotNet), inside my C# code, while still being able to properly edit them in an R project, with all the language support found there.
Still, if there is a better solution in someone's knowledge, please bring it!
First of all, i'am not looking for a code sample. I just want some directions on something am working on. I'am an intermediate C# developer and i'am developing something, something like a pet/side project [huh.., it's just a crappy form application :-)].
Currently am working on a ASP.NET MVC Web project. When our client request for a change, we make the change and publish the project, then we we copy only the modified/newly added files(.cshtml, .css, .js etc..) and bin files(.dll) (if there is any controller, model etc change during the development) and replace/add them to the server.
What i'am trying to achieve is, after publishing i run a form app and it list all the projects in TFS, then i can select a project and select any changeset associated with the project(usually the latest one or two changesets) and upon click next it finds the modified/newly created files (.cshtml, .css, .js etc..) and modified(modified on the day of publish) bin files(.dll) and copy to desktop in the same folder structure as publish folder as a single compressed file, it is kind of like automating the 'picking apples (or) files'.
I have almost completed the above however just to know is there any tools for this already available that i'am not aware of or is there some option in VS to perform this? Am just a developer and didn't know the endless possibilities of VS (which i'am excited each day while learning it..)
Also please note i don't want to publish all my files to server directly from VS which i'am already aware of.
[EDIT]
I know simply i can create a batch file to find modified files in a folder and do the needed (my rocket engineering solution above vs simply doing it..!! ). I just want to know is there something already in VS etc...
I am building a personal website using asp.NET's webforms in visual studio 2013 express for web and am following this tutorial:
http://www.asp.net/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-forms/introduction-and-overview
My page is structured exactly the same as in the website, I have changed some minor stuff to make it my own but the structure in terms of the C# classes and how the interact with the HTML are exactly the same.
I got to section 5 of the tutorial "Display Data Items and Details" and everything was working fine. I've used git a lot in the past so I decided to create a repository for this project so I can access it at work if I feel like.
Suddenly now when I make changes to the C# classes it won't build. It's even stranger because I if I make a change on an HTML file the change is built. In section 3 of the tutorial we learnt how to make the 'product' classes which are displayed on the products page. If I want to change one of the product names for example, when I build the change is not there. Simultaneously I went and changed some info in the HTML for the contact page, IT CHANGES when I build. Why wont the C# changes take effect when I build any more?
I am relatively new to both asp.NET and visual studio. The HTML changes when I build and the C# does not. When I change either I can see in solution explorer that there is a red tick for pending changes. Why would only the HTML pending change be included in the build and not the C#? How do I ensure that the build is actually building the version I see in my editor window?
EDIT
I do not know if I found the original cause but I found a solution/workaround. I realized that the classes mentioned above were grabbed by the html page from the page's database. The .mdf file for the solution was not being rebuilt whenever I cleaned and built so I physically deleted it and rebuilt the solution and voilla my C# changes occurred. I am still fairly new to this whole thing, can someone explain what the .mdf file does and why it wasn't being rebuilt?
Check your .cs files properties on the properties window in visual studio to make sure their Build Action is set to "Compile", Things that are not set to "Compile" do not get compiled. How MSBuild treats project items depends entirely on their build action. CS files default to "Compile" when you make them, but if you changed them yourself that would be why it doesn't update. Also CS files placed in the App_Start folder default to "Content" and they are compiled by ASP.Net when the Application Starts, so if you changed something in App_Start you need to reset the site.
Not exactly sure what is the problem, but I would do a right mouse click on the solution in Solution Explorer->Clean Solution, then do another build and see if that helps.
I've read about this technique: Shared assembly info in VS projects - JJameson's blog
Basically it means to create a SharedAssemblyInfo.cs with versioning information about the assembly, and adding this file as Link to all projects of the solution, so the actual file resides only in 1 location on disk.
My question deals with 2 scenarios:
Existing solution that doesn't use this mechanism: Is there a way to easily add the ShareAssemblyInfo to all projects? (lets say i have a solution with 50 projects).
When creating a new project, by default a new AssemblyInfo.cs is created. However i'd like to link automatically to the SharedAssemblyInfo as well.
Is there any solution for this? what is the common practice?
It is possible to link to a shared assembly info file in VS 2010. Ashish Jain has a good blog post about it: Sharing assembly version across projects in a solution.
After creating the shared assembly info file at the solution level, his instructions for linking to it from a project are:
Right click on the project, in which you wish to add the Shared
assembly file, and select Add -> Existing Item...
Select the file “SharedAssemblyInfo.cs” from the solution folder.
Instead of Add, click on the the arrow next to Add and click “Add as
Link”
Drag down the added linked file alongside AssemblyInfo.cs in the
same folder.
Repeat steps 1 – 4 for all projects for which you wish to add shared
assembly file.
I've tried this and it works.
First point could be solved with simple text editor that could handle several files at once and find/replace. Just open all of your csproj in it and replace string <Compile Include="Properties\AssemblyInfo.cs" /> with
<Compile Include="..\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
Alternatively you could write a utility like that:
var files = Directory.GetFiles(yourSolutionDir, "*.csproj", SearchOption.AllDirectories);
foreach (var f in files) {
string contents = File.ReadAllText(f);
string result = contents.Replace("<Compile Include=\"Properties\\AssemblyInfo.cs\" />", putSecondStringHere_ItIsJustTooLong); // :)
File.WriteAllText(f, contents);
}
As for the second question... You could take a look at Visual Studio custom project templates , but I'm not sure it worth the efforts. You should IMO write test that will check this instead. It will be much simpler and outcome is actually almost the same.
UPD: About writing tests for checking solution/project files against some custom rules. Basically, sln/csproj format is simple enough to be parseable without much efforts. So if you want to have SharedAssemblyInfo.cs linked into every project - just parse csproj's and check that. Then put that checker in your build server and run it on each build. We have such system working currently and it costs something about two days to write but saved us many more (we have there more sophisticated rules and multi-solution project, so it was worth the efforts).
I won't write about this checking in detail here right now (it is not that short), but I'm going to write blog post about it soon - most probably till the end of this week. So, if you're interested - just check my blog soon :)
UPD: Here it is.
I have created an application to increment the file version automatically.
Download Applicaiton
add the following line to pre-build event command line
C:\temp\IncrementFileVersion.exe $(SolutionDir)\Properties\AssemblyInfo.cs
Build the project
To keep it simple the app only throws messages if there is an error, to confirm it worked fine you will need to check the file version in 'Assembly Information'
Note : You will have to reload the solution in Visual studio for 'Assembly Information' button to populate the fields, however your output file will have the updated version.
For suggestions and requests please email me at telson_alva#yahoo.com
This does not work for solution that has both C# and F# projects. c# project cannot reference shared f# file and vice versa.
The only option in this case is to make a separate project and refer to it from other projects