Why do events stored in a separate tmc file reappear in my twincat .tsproj file? - twincat

I have a TwinCAT PLC project with events. When I first added the event classes they were stored in the .tsproj file. For source control purposes I moved these events to separate .tmc files. However, now whenever I switch my target system the event classes are re-added to the .tsproj file. The event classes are not added with a rebuild or reopening the project.
Why are these files added to the .tsproj again? They should not be needed here, since they are stored in the .tmc files. I'm using TwinCAT 4022.29.

The answer came to me when I tried to move the events into a separate .tmc file in a TwinCAT 4024.12 project. It turns out you need to uncheck "Persistent (even if unused)", as you can see by this clear tool-tip when the check mark is still there.
To remove the "Persistent (even if unsed)", right click on the event to uncheck the option.

Related

TFS source control - new files not automatically detected as pending changes

As per the tags, I'm using VS2013 and TFS2013.
There are multiple projects in the solution: Model, Presenter, View, etc. All other projects are working as expected in terms of source control operations.
Problems with the Model project:
Adding a new file via Solution Explorer isn't automatically detected as a pending change
Deleting a file isn't detected either
Other source control operations work fine for the Model project, such as:
Get latest version
Edit detection for existing files (including changes to the csproj
file when a new file is added)
Checking in pending changes
The csproj file would show up in pending changes with the newly added file listed in it, but the new file itself isn't showing up, therefore causing build errors on other developers' machines if only the csproj changes are checked in.
The workaround is to find the added file in solution explorer and Add via context menu, this will make it appear as a pending change. But this process should be automatic as per the other projects.
Noticed that there is no .vspscc file for the Model project while other projects have one each.
Any help appreciated. Thanks.
I would unbind and rebind the problem project and try again:
To unbind a solution or project from source control
In Visual Studio, open Solution Explorer and select a solution or
project to unbind.
On the File menu, click Source Control, then Change Source Control.
In the Change Source Control dialog box, click Unbind.
To bind a solution or project to source control
In Visual Studio, open Solution Explorer and select a solution or project to bind.
On the File menu, click Source Control, then Change Source Control.
In the Change Source Control dialog box, click Bind.
Select the database and location to which to bind, and click OK.
Click OK.
You might need to go to Advanced to find the Change Source Control option
https://msdn.microsoft.com/en-us/library/0eh3790h%28v=vs.90%29.aspx
Before unbinding and binding your solution try his:
Go to Source Control Explorer
Click the "Add Items to Folder" (the
one on the left of the red cross)
Select the items you want to Add and follow the instructions on screen
That's all
Click <Detected: x add(s), x delete(s)> : in the source control explorer then select the file to add
For years I've been relying on 'Detected Adds' to add missing files - which was never a sustainable solution but I've just about managed with it.
But now if broke.
I'm actually about to reinstall Windows but in the meantime one of the best ways I've found to get a sense on what's missing (and it's still working even though the detected adds isn't) is the recursive 'Compare' window.
You can add files from here too.
It's a little klunky but it gives me a good sense of security and shows file diffs if you want to see what may have changes.

MFC Menu won't propagate into application

I'm working on making slight changes to a legacy VS 2008 & MFC project, including changes to the WinAPI/MFC *.rc resource file. I have made those changes, e.g., changing a menu string (for IDR_MAINFRAME, if it matters) from "New Scan" to "New Organism" on one computer, commited to VCS, and tried rebuilding the project on another, practically identical configuration (not sure if relevant), which is when I ran into problems.
Currently, I have
changes to the menu from within the VS resource editor that do not propagate into the application (old values remain)
changes to the about dialog that do propagate into the application
an RC file that contains no mention of "New Scan"
no file, including binaries, containing "New Scan" (though, as mentioned, this might be due to encoding)
I have
cleaned and rebuilt
manually cleaned and rebuilt
deleted the *.res file and compiled just the *.rc file into a *.res just to make sure the paths there are alright
modified the configuration so that (Project -> Properties -> Resources -> Command Line) has an absolute path to the *.res file.
verified that the current module is indeed the exe being executed via GetModuleHandle
verified that all calls to FindResource and LoadResource pass NULL as the current module, meaning the resource should be loaded from the exe
verified using ResEdit that the resource within the exe contains "New Organism", even though it shows "New Scan" when run. I verified the #define for the resource is the same number as the number reported by ResEdit. Verified there's no other similar resources in the exe.
verified that I'm running the same exe I'm inspecting and tried running it from both the IDE and from Windows Explorer.
inspected all (two) non-system DLLs that get loaded (as reported by the output window and dependency walker) using ResEdit and both of them belong to a 3rd paty library and none of them contain any menu resources (they only contain manifests).
tried changing/removing the command that loads the menu (CFrameWndEx::LoadFrame) and verified it forces the application to fail.
verified that having an IDR_AppnameTYPE MENU with a second copy of the menu doesn't help (see thomiel's answer below)
Using google
To no avail. I am especially unsure where the original string, "New Scan", is coming from and how come changes to my about dialog propagate and changes to the menu don't. How do I make the changes to the menu propagate to the *.exe itself?
In case of a SDI or MDI: Not only change IDR_MAINFRAME but also IDR_??????TYPE, which is the menu displayed when you have an open document.
I have had the exact same problem. This is going to sound crazy, but if you create a SUB menu in the menu item, and then delete the APS AND RES files, and then SAVE ALL and to a REBUILD of the ENTIRE SOLUTION, you should be OK. Please contact me if you have any other questions. I'm happy to help.
It seems that MFC will cache the menu items in registry when you quit your application. To prove it you can copy your program to a new machine and runs it. If it displays the modified menu items normally, it means MFC uses cached menu items on your own machine.
You can clean the registry key to make your modifications take effects. The registry entry may locate at
HKEY_CURRENT_USER\Software\Local AppWizard-GeneratedApplications\MyMFCApplication1
-or-
HKEY_CURRENT_USER\Software\{your company}\{your project name}\Workspace
based on the MFC version.

Xcode: Tabbed workflow

In Xcode I use a task-based tabbed workflow (a separate tab for editing, UI/Modeling, building, debugging, etc.). I accomplish this using Behaviors (see the Custom section in the attached screen shot). When I create a new Project I use press ⌘+1, ⌘+2, etc. to quickly setup all of my task tabs.
My issue is that when I do this for a newly created Project all of the tabs display the source, storyboards, etc. from my most recently open Project. How often do you think this is useful or the desired behavior? I realize that one of the great things about tabs is that they remember their state and this is helpful. But as far as the source files that are initially displayed, this is a real pain. I do not want to see files from other (generally unrelated) projects.
Now what I just did as an experiment was open Project A and setup all of my tabs and ensured that each tab contained a source file from Project A. Then I quit Xcode and moved Project A a new location on the file system. When I opened Project B and created all of my tabs they were, as desired, empty.
I realize that I'm just going to receive the canonical "File a Radar" here but in the off chance that there is a workaround (NOT moving files) or a preference I could set, I figured I'd at least ask.
Thanks in advance,
CS

How can I protect a source file when debugging?

I've got an app that uses our DAL and when I run it in debug mode (vs2010) and purposely try to make the app crash (for instance, leave the connection string empty of the DAL), vs2010 opens the code for the DAL at the point in which it crashed. Which is ok, but I'm then able to edit that .cs file and save changes, which I don't want. I've verified this by having the DAL project opened in another instance of vs2010 and when I make the app crash and change the DAL.cs in the app and save it, the DAL in vs2010 tells me that the file has been modified outside the project and asks if I want to reload it.
How can I prevent this from happening? The only reference I am using to DAL in my app is the reference to the DLL, that's all.
The AssemblyName.pdb file links the compiled DLL to the original source.
Visual Studio uses this file to display the source code when debugging.
You can delete this file and get rid of the source link.
This will give you a vastly inferior debugging experience.
Have you tried going to "Tools > Options > Debugging > Edit and Continue" and unchecking "Enable Edit and Continue"?
Make the .cs file(s) read-only. If its read-only, you'll be able to see it, but you won't be able to save changes. (Depending on your Visual Studio settings, you might still be able to edit the file in memory, but that seems irrelevant, since the changes you make won't be persisted to disk.)
If you need more fine-grained control (like where you want to be able to edit the source files, but not your testers), you can use access control lists (ACLs). Ask more questions about that on Server Fault.
Yes, you could disable debugging or turn off the generation of PDB files, but that makes it very difficult to debug the code, which is probably the reason why you're purposely trying to make the app crash.

How do I make a graphical asset in Visual Studio update?

I'm working on an XNA project and modify a graphical asset outside of Visual Studio. In order for those changes to show up in the application, I need to remove the reference to the original image, and then re-add the same image to see the changes. This happens whether I do a complete rebuild or not. Is there a way to streamline this process so that my project shows the changes I've made without having to remove the content reference and then re-adding it after each change.
XNA is pretty smart, and only wants to re-run assets through the content pipeline when it detects something has changed. For some reason it isn't seeing the changes you are making.
Make sure you are modifying the correct file. For example if your original image is at c:\myImage.png and your project is as c:\myGame when you add the image to the Content Project it gets copied to c:\myGame\myGameContent. Editing the image at c:\myImage.png wont get noticed. You need to edit c:\myGame\myGameContent\myImage.png
If you are editing the correct file and it still won't update, try touching another file. As smart as the engine is, it will run everything through the Content Pipeline when it detects 1 item has changed.* If that still doesn't work If you look at the top of the Solution Explorer there is a refresh button. Try pressing it as it should make sure your Solution Tree is in sync with the files on disk.
*note this is true for v3.1 it could have changed for 4.0
When you drag an item into a Visual Studio project (like, in this case, a Content Project), it will copy the file into the project directory. By default it does not reference the file you drag in (although that is available as an option).
(If the file you drag in is already in the project directory, it just leaves it there.)
The upshot of this is that you need to work on your content files in the content project directory, if you want to see your updates happen immediately.
If you don't know where the files are being copied to, select one of them in your content project and press F4 (properties window). Find the "Full Path" entry. That is where your files are stored.

Resources