Copy application config file to another application directory - unit-testing

I am testing a WCF service, which is hosted in a console application. I am running the test using NUnit. So I want to copy the console application and app.config of console application to the Bin\Debug folder of the Test assembly. I am able to copy the console application, by adding the reference to the test assembly, but app.config of console application is not coming. Also I tried to copy by setting the properties, it not worked. It is copying the app.config as it is, it not changing the name as ConsoleApp.exe.Config. Is there any way to fix this issue?

you can create a post build event to do this, which will copy the projects app.config and will rename it ConsoleApp.exe.config.
You could also just create a file in your project called ConsoleApp.exe.config and fill it with the config required for the tests and have it copy to the output directory. this would be my preferred solution as it would mean that the tests would be in control of the config and would not be affected by the potential changes to the app.config in the console applications project.

Related

Codename One: Webservice not available

I used the CN1 Webservice Wizard to add a the webservice proxy to my mobile app and to generate all the server side code. I have a local XAMPP installation with a tomcat linked within my Eclipse IDE. Also, I imported the server generated code as a new Java Project and added the "Dynamic Web Module" project facet to it so that I could launch it not as a local Java application but rather on the Tomcat server.
When starting my client, I noted that I get HTTP 404, resource not found errors. I traced the error back to the URL, where the server is hosted to.
I know I have to adapt the urlPatterns parameter in the generated class CN1WebServiceServlet, which I did. Also, I checked the context of my app in the Web project settings and defined the value for context root. So, in my client app, the URL to call the service should be
http://localhost:8080/< context root>/< urlPattern>
However, even when calling that in the browser, I should get the result of the doGet method of the server generated code, showing the message "Webservice access only". Instead, I get 404 errors all the time.
Is there some problem to importing the server generated code as a plain Java project and adding the web parts to it afterwards? How would that be done in the ideal case?
And what other problems might be hindering the URL from properly being published on the server side?
Thanks and best regards
EDIT
I stripped everything from the project to limit the options and I found the cause: when using the web service wizard to dump the source files into a new directory, adding that with the Eclipse import wizard, it will be looked at as a plain java project without any web components. Using the project settings to add the dynamic web piece to it (Eclipse calls those project facets), the CN1 webservice will NOT work.
If instead you create a "Dynamic Web Project" first and then use the CN1 Webservice Wizard to dump the server source files into the "src" folder of that project, it works without any issues.

dll is not updating in production server

I have a Visual Studio project developed in asp.net that calls a .dll developed in C++. I modified the .dll file and replaced the old file located in the bin folder. Locally, the website worked fine. I did the same in the production server, but the change was ignored, the web site behaved like the previous file. Why?
I did a test leaving the message “new version” in .cs file to check if it is updated in the production server. And it is indeed.
I did another test cleaning the history browser, but the problem remained.
In another test, I removed the dll file from the bin folder, and the website continued to work normally. How is that possible?
I read from a forum (link) that asp.net makes a "shadow copy" of the files and loads them from the copy. But it should not be a problem.

import projects in build path for web service: server or client?

I have created a little example app to test out the CN1 web service functionalities. Following the web service tutorial from CN1 (https://www.codenameone.com/how-do-i---access-remote-webservices-perform-operations-on-the-server.html), I have my Codename one project as client and a dynamic web project running on my Eclipse tomcat server hosting the servlet.
As I have objects that I pass back and forth between client and server, I want both projects to know about these java files. The way to do that is to put the file in one project, and modify the build path of the other to include the first project. This way, the import can resolve the file name just fine.
Question now is: is it better to put the files in one project or the other? Does either way affect the size of the resulting app file that I want to publish in a store? I want to keep the size as small as possible.
Thanks for any tips.
UPDATE: on the preliminary information provided by Shai, files that are to be shared among different projects (either client or server side), do not put your code in either but INSTEAD create a CN1 library for that. This library can then be added to the CN1 buildpath configuration (not the Java build path!) to all required projects.
Here are the details on how and why: https://www.codenameone.com/blog/new-preliminary-library-support.html
Just need to figure out how to do this on Eclipse, as it does not seem to be supported now.
You can use shared code with a cn1lib whose source you can include into the server project manually. In some cases we just copy the shared source files in the build script from one project to the other as it makes the process simpler.

Wsdl never updates

No matter what I change in an asmx service in Visual Studio, the WSDL file stays always the same. Deleting methods, changing method signatures don't have any effect when I browse to service definition.
I have had a simular problem.
When removing an enum and replacing it by a string, the enum wouldn't go away from the wsdl. No matter what I tried (clean, rebuild, clear browser cache, other browser), it kept returning the enum as a complex type within the WSDL.
The solution in my case was remove the local folders of the project via windows explorer, then perform a get latest from TFS. After this the problem was solved.
Of course this solution only aplies when using a sourcecontrol system.
After changing your service, you must build it and ensure that the new version is running. One shortcut would be to build it (and make sure there are no errors), then right-click the .ASMX file and choose "View in Browser".
Also, although I'm sure you're aware of it, you should not be using ASMX web services for new development. Microsoft now considers ASMX to be a legacy technology. Use WCF instead.
I have encountered this problem and have a solution.
Cause: When you create a new "Web Service" project in Visual Studio, it automatically adds a "Service1.asmx" file to your project. You rename this file and change the class declaration inside of it, but Studio still thinks it's "Service1" wnd will only ever display the web service definition for "Service1".
Solution:
Delete all "bin" and "obj" folders in your project.
Copy the methods from your existing asmx file to notepad.
Remove the service from your project.
Add a new service to your project, with the name you want.
Paste the code from Notepad into the new service.
Rebuild All
Your asmx should now accurately reflect your web service and update normally on future builds.
I had today the very same issue. It was caused by a GACed version of the assembly that contained the type definitions exposed by the web service. I had to remove the assembly from the Global Assembly Cache first, like:
"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\gacutil.exe" /u YourAssemblyNameWithouthDllExtebsion /f
Be sure to restart the web server hosting the web service to reload the new version of the assembly, for example, in case of IIS Express, you can kill the former process instance by PowerShell:
(Get-Process -Name iisexpress).Kill()
After that, the updated WSDL version was displayed as expected.

Web Service URL Problem

H!,
I have a solution in which there is several other sub projects (windows application).
in every project I have some web services added.
Now the problem :
how can i set the URL of each web service individually from the app.Config file??
is there a setting I missed to set ?
can it be automatically done or I have to code for it ?
Thank you friends.
There is only 1 app.Config file per executable - although the app.Config file is named app.Config in the solution, it is in fact renamed to the same name as the end executable:
So for example if my output executable is called Test.exe, the app.Config file will be named Test.exe.config.
Only config in that file has an effect - thats the file you need to set your web service URL in.