Ghost Process Writing to Visual Studio 2008 Debug Immediate Window

November 4, 2009 by slightlybehindthecurve

If you’ve never seen something like this, you might not believe it.

In debugging a website running under, I had debug.print lines from another website appearing in the immediate window.
They stopped if:
1) I shut down IIS (of course, that killed my debugging as well)
2) I detached the asp_wp worker process from the debugger (and then I couldn’t debug my own project)
3) killing the asp_wp processes from Task Manager gave a brief respite, but the messages started again once the worker process was reactivated.

What I finally did, and this is a temporary fix, is to luckily guess the offending website under IIS, and rename the directory. Now, that website is not able to be browsed.

I had only one instance of IE or any other browser open during the time when I was trying to fix the problem. (generally I have many open)

I suspected some scheduled process browsing to the website – that is still a possibility.
Also, I suspect a coding practice of mine, which is to use some debug logging code in static (vb – shared) functions. Perhaps IIS is for some reason opening this virtual directory? (I know I said web site above, but actually I mean a virtual directory under the same website running in the same IIS .Net 2 process.)
Also, the virtual directory in question was the last one in alphabetical order of all my virtual directories.

I did not search Knowledge Base about this. It’s something I’ve lived with for weeks, at least, and just ignored, until this AM.

asp.net 1.1 set page title in code

October 29, 2009 by slightlybehindthecurve

This is easy:
in aspx

in form load:
sParam = Request.Params(“strkey”) & “”
‘Me.HtmlTitle.TagName = sParam
Session(“title”) = sParam

initialize soap from ASP

September 23, 2009 by slightlybehindthecurve

Soap doesn’t like relative paths, but I want to create a path string so that my code runs both locally and on the server.

' 1) web service setup
dim servername
servername = request("SERVER_NAME")

dim strSoapObjectLibrary

if ( lcase(servername) = "localhost" ) then
strSoapObjectLibrary = "MSSOAP.SoapClient" ' works on WinXP
else
strSoapObjectLibrary = "MSSOAP.SoapClient30" ' change this to match whatever library is installed
end if

SET svc = Server.CreateObject(strSoapObjectLibrary)
svc.ClientProperty("ServerHTTPRequest") = True

' make the path to the web service somewhat dynamically
dim sPath
if ( lcase(servername) = "localhost" ) then
sPath = "http://localhost"
else
sPath = "https://" + servername ' change this to match whatever library is installed
end if

sPath = sPath + "/WQQQ2/ws/wsQuotes.asmx"
sPath = sPath + "?WSDL"
'response.Write(sPath)

Call svc.mssoapinit(sPath,"wsQuotes")

web service to return html , javascript converts return string

September 18, 2009 by slightlybehindthecurve

I had to make a kind of “quote of the day” web service. Then I changed it so that the returned text could be html formatted instead of just plain text.

That caused a problem for me, because while the html saved in my database looked good (bolds and line feeds etc), when my calling routine got the text out of the web service, it converted all the less than signs to < and the greater than signs to >.

I don’t know if this is a good solution, but here’s what it does:
INPUT STRING:

<?xml version=”1.0″ encoding=”utf-8″?>
<string xmlns=”http://tempuri.org/”>Yabba Dabba Doo.
&lt;br&gt;&lt;br&gt;

&lt;bold&gt;Fred Flintstone&lt;/bold&gt;</string>

OUTPUT STRING:

Yabba Dabba Doo.
<br><br>

<bold>Fred Flintstone</bold>

Here’s the routine:

 


// ---------------------------------------------------
// purpose - does a simple parse of the xml response to get the string we're interested in
function ajaxws_get_response_html(sXML) {
var sResponseText;
var iFirst = sXML.indexOf('org/">') + 6;
var iLast = sXML.indexOf('', iFirst);
sResponseText = sXML;

if (iFirst > 0 && iLast > 0) {
var iLength = iLast - iFirst;
sResponseText = sXML.substr(iFirst, iLength);
}

sResponseText = sResponseText.replace(/</g, '');
return sResponseText;
}

 

Here is where it fits into the set of routines to call a web service from the browser:

 

 

// purpose – ajax like routines to get data from the web service
var xmlhttp = null; // the init function will set this, it is the xml object that calls the server side function

var sReturned_Data;
sReturned_Data = ”;

var url_base = ”;
url_base = ‘ws/wsquotes.asmx/GetQuote’; // syntax for non-soap url
var debugjs;
debugjs = 0; // set the debug variable to 0 to turn off the alert messages
if (debugjs > 3) alert(‘page loaded, ajax_updater’);

// —————————————————
// purpose – try to guarantee that the activex object gets instantiated
// if ajax is not initiated when we call it the first time, then this sub makes sure that it gets initiated
function ajaxws_Init() {
try {
// Mozilla / Safari
xmlhttp = new XMLHttpRequest();
}
catch (e) {
// Explorer
var _ieModelos = new Array(
‘MSXML2.XMLHTTP.5.0′,
‘MSXML2.XMLHTTP.4.0′,
‘MSXML2.XMLHTTP.3.0′,
‘MSXML2.XMLHTTP’,
‘Microsoft.XMLHTTP’);

var success = false;
for (var i = 0; i 0) alert(‘ajaxws_CallWebServiceUpdater – id:’ );
if (debugjs > 0) alert(‘ajaxws_CallWebServiceUpdater – url:’ );

xmlhttp.open(“GET”, url, true);
xmlhttp.onreadystatechange = ajaxws_stateChanged; // http://snippets.dzone.com/tag/xmlhttp
xmlhttp.send(null);
// http://www.devguru.com/technologies/xmldom/QuickRef/obj_httpRequest.html
}

// —————————————————
// purpose – called by ajax event
function ajaxws_stateChanged() {
if (debugjs > 0) alert(‘ajaxws_stateChanged ‘);

if (xmlhttp.readyState == 4 || xmlhttp.readyState == “complete”) {
sReturned_Data = ajaxws_get_response_html(xmlhttp.responseText);
}
}

// —————————————————
// purpose – does a simple parse of the xml response to get the string were interested in
function ajaxws_get_response_text(sXML) {
return sXML;
var sResponseText;
var iFirst = sXML.indexOf(‘/”>’) + 3;
var iLast = sXML.indexOf(‘ 0 && iLast > 0) {
var iLength = iLast – iFirst;
sResponseText = sXML.substr(iFirst, iLength);
}
return sResponseText;
}

// —————————————————
// purpose – does a simple parse of the xml response to get the string we’re interested in
function ajaxws_get_response_html(sXML) {
var sResponseText;
var iFirst = sXML.indexOf(‘org/”>’) + 6;
var iLast = sXML.indexOf(”, iFirst);
sResponseText = sXML;

if (iFirst > 0 && iLast > 0) {
var iLength = iLast – iFirst;
sResponseText = sXML.substr(iFirst, iLength);
}

sResponseText = sResponseText.replace(/</g, ”);
return sResponseText;
}

Read the rest of this entry »

when visual studio debugging doesn’t work right

August 26, 2009 by slightlybehindthecurve

I have had issues both with visual studio 2008 using cassini and even also with visual studio 2003!

Here is the issue:
I need to trace into some code in a code-behind web page, but visual studio decides not to trace to my breakpoint, but just displays the page.

I think the root cause is related to:
1) multiple instances of aspnet_wp.exe that seem to somehow get created (I run the debugger literally hundreds of times a day, and the extra cassini instances do happen)
2) weird hidden iexplore.exe processes that are left hanging out there messing around with my new debug instance
3) some weird state that my local iis has gotten into (especially for 2003)

And that’s about the extent of the theory that I understand.

Fixes:
1) restart iis with net stop w3svc, net start w3svc (for 2003)
2) killing the unwanted cassini instances
3) killing iexplore.exe processes from task manager (this means you have to listen to pandora with Firefox!)
4) and/or restarting visual studio

list all logins of a server

July 14, 2009 by slightlybehindthecurve

I’ve found some tremendous resources for administrative sql scripts:
in general:
http://vyaskn.tripod.com/generate_scripts_repetitive_sql_tasks.htm
for the one I’m posting about: http://demiliani.com/blog/archive/2005/05/13/2449.aspx

But , you may ask, why should you get excited about some complicated sql script that generates other sql script that you must copy past and execute? Well, I have a server where someone created the SA userid, and it’s probably been there forever, and I’d like to get rid of it, but how do I know which databases it’s being used for?

put all the logins into a table:
1)
use master
select
'insert into loginstemp select ''' + name + ''' as DBName , name as Login from ' + name + '.sys.sysusers where islogin=1 '
as 'CopyAndExecute'
from master.dbo.sysdatabases

2) create temp table
use MyWriteTable

drop table loginstemp

create table loginstemp (DBName varchar(50), [Login] varchar(50) )

3) copy and execute the generated sql

use MyWriteTable

insert into loginstemp select 'ATable' as DBName , name as Login from ATable.sys.sysusers where islogin=1
insert into loginstemp select 'MyWriteTable' as DBName , name as Login from MyWriteTable.sys.sysusers where islogin=1
etc.

4) view temp table
use MyWriteTable
select * from loginstemp

size of all tables in a database

July 13, 2009 by slightlybehindthecurve

purpose – what if some tables are growing a lot more than you expected? wouldn’t it be handy to have a snapshot of how large all your tables are?


-- replace DB2Data for your own database
use db2data

if exists (select [id] from tempdb..sysobjects where [id] = OBJECT_ID ('tempdb..#TempCountRecords '))
DROP TABLE #TempCountRecords

CREATE TABLE #TempCountRecords (
[Table_Name] varchar(50),
[CountRecords] int
)

declare @SQLcommand varchar(200)

declare @TableName varchar(50)
declare @TableSchema varchar(50)
DECLARE c_db CURSOR FOR SELECT table_name, table_schema from information_schema.tables where table_type='base table'

OPEN c_db
FETCH NEXT FROM c_db INTO @TableName, @TableSchema
WHILE @@FETCH_STATUS = 0
begin

set @TableName = '['+@tableschema + '].[' + @tableName + ']'

set @SQLCommand = ' select ''QQQ'' as [Table_Name] , count(*) as [CountRecords] from QQQ '
set @SQLcommand = replace( @SQLcommand , 'QQQ' , @TableName )
print @SQLcommand

-- insert and execute all in one statement - refer to ms_Script.sql in the Status_DBQueries
insert #TempCountRecords
EXECUTE (@SQLcommand)

FETCH NEXT FROM c_db INTO @TableName, @tableschema

end
DEALLOCATE c_db

select * from #TempCountRecords order by CountRecords desc
drop table #TempCountRecords

mvc – RouteTable not defined

July 7, 2009 by slightlybehindthecurve

It’s kind of a bummer when you try to make you’re first asp.net mvc app, just select the defaults, and get a lot of weird errors.
For me, in global.asax, RouteTable and RouteCollection were not defined.
1) I noticed in comparing my global.asax to an example I found somewhere that the following lines were missing from mine:
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.Mvc
Imports System.Web.Routing

2) but to get system.web.routing to be valid, I had to include some references. This is what I found at
(http://www.packtpub.com/article/mixing-asp.net-webforms-and-asp.net-mvc)
“add a reference to the following three assemblies to your existing ASP.NET application:”

System.Web.Routing
System.Web.Abstractions
System.Web.Mvc

So now my “hello world” app actually builds.

Asp.Net MVC template problem

July 6, 2009 by slightlybehindthecurve

Text of the problem (as I type it in):
Error: this template attempted to load an untrusted component ‘Microsoft.VisualStudio.Web.Extensions, Version=9.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35′. etc.

Resolution: downloaded and installed Asp.Net MVC 1.0 from http://www.microsoft.com/downloads/details.aspx?FamilyID=53289097-73ce-43bf-b6a6-35e00103cb4b&displaylang=en

Root Cause? perhaps I had a beta already installed that I had never attempted to use before.

add podcasts to your creative zen player

June 5, 2009 by slightlybehindthecurve

I used to use the media manager tool that creative supplied, but I think it’s easier to just use windows explorer. (this works in vista as well, but I’ll explain XP here)
1) get to your iTunes podcasts folder in one instance of explorer:
mine is at: C:\Documents and Settings\myNameHere\My Documents\My Music\iTunes\iTunes Music\Podcasts

2) open the zen in another instance of explorer
mine is at: My Computer\My Zen

3) drag a podcast mp3 file to your zen (for example My Computer\My Zen\Storage Media\Music\stocks)

4) open a playlist by clicking on it
(look in My Computer\My Zen\Storage Media\My Playlists)

5) from the zen explorer, drag a file into a playlist.

I think this is a lot faster than using the creative supplied tool, but I’m glad they supplied us with it.