Possible to Add ServiceReference (ASMX) to Visual Studio Template (VSIX)? - c#

When I add a Service Reference ("MyWebService.asmx") to my template, I have two issues.
The References.svcmap always has things like: Silverlight_Application_Template.MyWebService.ZrrayOfXElement.datasource. I don't think I really want the template name in the file name. Instead, I would like for them to get renamed to something more like: "$SafeProjectName$.MyWebService.ZrrayOfXElement.datasource" where "SafeProjectName" is what gets replaced by the name the user enters for the project when they create the template.
I get a PathTooLongException when I run the VSIX, because of the file listed above.
Is there a way to get this to work? I could just tell the users to add a ServiceReference immediately after they create a project using the template, but eliminating an extra step is always nice.
Thank you for reading and for any/all help/tips/suggestions. Have a great Wednesday!

Related

ASP.NET Core Web App and windows form app give different results on service references

I try to add service references on ASP.NET Core Web App. That results app reference.cs file is mostly missing, classes are empty etc and only 100 lines.
But -even in same solution- if i try to add the same service reference in windows form app, all methods, interfaces and classes
are completely correct.
If i try to add web references in ASP.NET, theres no missing but i need to use WCF.
I try to copy other references file and paste it but it wont work.
What did i miss?
Note: I already check this answer and subject but it will not work first time and question isnt same. My reference.cs file isnt empty,and also theres no change even i try 100 time it will be the same output - this question pointed coincidence - so it is NOT duplicate question. Thanks.
After 5-6 hours thanks to this beautiful answer - actually i tried this before - and with my add ons, i figure it out.
Delete the reference - right click and delete -
Check file explorer, make sure no files in Connected Services.
While your project is highlighted, right click on project and select clean
After all of that, add your service reference and -just like the answer said- make sure reuse types in referenced assembles is not checked.

How can I use custom template parameters gathered with TemplateWizard in the project (not source) file?

In VS2017 I've made a C# Project Template project, that uses forms and the IWizard interface to pop up a dialog as soon as the user types a project name and hits OK. The form gathers info from the user and then sets up the new project accordingly.
I haven't really detoured from the guide mentioned in the next line, except it doesn't cover what I'd like to do.
Note to future readers: This How To Use Wizards With Project Templates guide is the only version of the page I have found that points out the need for the System and System.Drawing references. And even then it says "assemblies" when it means "references". Other duplicates of the same page have a strangely blank space at the crucial moment.
So inside IWizard's RunStarted() function, I create custom template parameters that look $like$ $this$, add them to the replacementsDictionary, and assign values to them that I retrieved from my whiz-bang pop up dialog. The wizard will then substitute appearances of those custom parameters that it finds in files of the new project (I wrote those appearances earlier), with the values I assigned to them. There are also built-in template parameters that I can use in the same way.
What I can do (source files == .cpp, project file == .vcxproj):
Use built-in template parameters to substitute values into my template's source files and project file.
Define custom template parameters inside the .vstemplate file that substitute values into my template's source files and project files.
Define custom template parameters inside IWizard's RunStarted() function that substitute values only into my template's source files.
What I can't do:
Define custom template parameters within IWizard's RunStarted() function that substitute values into my template's project file.
From what I understand, the first moment I can turn user-defined values into custom parameter values is via the RunStarted() function. This is the crux of the problem, as this is apparently too late to sub anything new into the project file. In the end product project file, all built-in template parameters get substituted as expected. All my custom template parameters that I defined in advance in the .vstemplate file are also subbed as expected. But the custom template parameters that I need to set up in RunStarted()... they still all look $like$ $this$.
In other words, if I write this inside RunStarted():
replacementsDictionary.Add("$custommessage$", "Custard");
then my source files will now have occurrences of Custard, but the project file will still only have $custommessage$.
This is forcing an XML-writing work around that is bringing its own problems, so I have come back to this. How can I get user-defined custom template parameter values into the project file?
It's the question that is broken. Template parameters do work in the project file straight off the bat. If they aren't working, it means something is wrong somewhere else. Ie., double check all your template parameters are working, are getting values, etc. It's typically one of them going wrong that causes the grief that inspired this question.

How to compile Item Template Project for Form with substitute parameters

I am trying to make an ItemTemplate for a Form. I create a "c# Item Tamplate"-Project, make my Form, and create my Template by Building the project. That works fine.
Now I want to add Templateparameters but as soon as I do, the project wont compile any more. It throws many different exceptions because the code is no longer valid. How can I solve this problem?
Here is what I tried so far:
Replacing every occurrence of my Classname with $safeitemname$. This, as I already said, throws exception because now the code is invalid and the project can not be built.
Creating CustomParameters in my .vstemplate to change a valid class name to my desired parameter (Classname -> $safeitemname$). This does nothing, even though I set "Replaceparameters="True"".
Ignoring the compiler warnings and implementing the project in my .vsix project anyway. This does nothing either, because the .zip for my template still can not be.
Setting DependentUpon of my Classname.Designer.cs to my Classname.cs. This does nothing either.
Trying a simple ItemTemplate with one class that's divided in two partial classes that have one Property each. Same thing as with the Form. It can no longer be build.
As Reza Aghaei suggested in his comment, the problem was, that I didn't set the build action for the files in my project to 'None'.

Want to install same application but with different name in WP7

I have an application lets say "Application1" .I want to install same application but by changing some contents in it and also its name like "Application2" so that both application1 and application2 can be seen on device?
Is this possible?If yes,then can someone kindly help as to how to do it.
EDIT:
Just if somebody else might need it, I got this done.
Get a GUID from a GUID generator tool and use this new GUID in WMAppManifest.xml and replace ProductId in this file and GUID in AssemblyInfo.cs.Rebilud the solution and its done!
Creating a new app with exactly the same content is very easy:
Create a new project and name it with the new name.
Remove the pages/classes created by default in the new project.
"Add as Links" all the pages/classes from the original project.
If you want to have different content in the second app, just put the different content in a separate file and use that rather than a linked one. (Partial classes split across multiple files make this very easy.)
Another way to customize content in the second app is to define a partial method in the original app but only implement this in the second app (in a partial class/file which only exists in the second app). In the implemented partial method add your changes to override the default (original app) behaviour/layout/whatever. - This is a good way of altering pages where you don't want to have to put customization into an already existing app. You just "override" it in the second app.
You would need to submit the two slightly different applications to the market as separate applications in order for them to be seen on the user's device.
As Matt suggests, if the two applications have a lot in common, then you can use linked files to reduce your maintenance overhead.
In addition to Matt's suggestion, I've done this for Free/Paid versions of the same app.
It's pretty easy to do. The files to change between versions are:
the icons
the splash screen
the mobile XML file in the Properties folder
The important thing in the XML file is the GUID identifying your app. This GUID doesn't seem to be used in the Marketplace - but it is used by the debugger's deployment functionality.
You can also use a project level #define to include/remove any other code you want different between the projects.

Enum Intellisense Display Attribute?

I want to do this:
enum Foo
{
[Display="Item One"]
ItemOne,
}
So that Intellisense will display it like in the attribute instead of the actual name.
I know it's possible, I've seen it before.
Well you could provide XML documentation:
enum Foo
{
/// <summary>Item One</summary>
ItemOne
}
I'm not sure whether that's quite what you were thinking of, but here's an example of what it looks like in VS 2010:
Note that I'm assuming you mean from the code editor... if you mean within a property editor, that could be something entirely different, e.g. DisplayNameAttribute (although that's meant for properties, events or methods).
If you know an example of what you want within the framework, we may be able to help more.
As a note... if you are building a .dll that is to be referenced by another application, just writing a summary will not allow the text to show up in intellisense for the referencing application. To accomplish this, you must deploy the XML documentation file as well, which requires a re-compiled version of the same .dll.
To do this (in VS2008 anyways), go into the Properties of your project, click the Build tab, click the checkbox at the bottom next to 'XML documentation file:', rebuild the application, and now you have the files needed to make it work.

Categories